BINGO! I wabt to take you out to a fine romantic dinner, thanks.
On Sep 5, 12:02 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Sep 5, 2008 at 2:50 PM, Robocop <[EMAIL PROTECTED]> wrote:
>
> > Hello,
> > I'm not entirely sure what the problem is, but as it stands, i'm
> > fairly confident this stupid little line of code i have should work.
> > The relevant models are:
>
> > class Encounter(models.Model):
> > service = models.IntegerField(max_length = 100, blank=True)
> > patient = models.ForeignKey(Patient)
> > day = models.DateField()
> > class Admin:
> > pass
> > def __unicode__(self):
> > return self.patient.name
>
> > class Service_details(models.Model):
> > name = models.CharField(max_length = 18, blank=True)
> > encounter = models.ForeignKey(Encounter)
> > attended = models.BooleanField(default = False)
> > class Admin:
> > pass
> > def __unicode__(self):
> > return self.name
>
> > And all i'm trying to do is sort "Service_details" by Encounter.day,
> > and the line i'm trying to do it with is:
>
> > Service_details.objects.filter(encounter__day=date)
>
> > where date is of the form 'YYYY-MM-DD,' but i always receive the
> > error "TypeError: Related Field has invalid lookup: day." This is a
> > little confusing to me as i'm staring at the day attribute in the
> > Encounter model right now. Any thoughts or help would be greatly
> > appreciated.
>
> I believe your 'day' field reference is getting interpreted as a 'day'
> lookup:
>
> http://docs.djangoproject.com/en/dev/ref/models/querysets/#day
>
> To avoid that and make it clear what you are after, try:
>
> Service_details.objects.filter(encounter__day__exact=date)
>
> Karen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---