Chris Ryland wrote: > One more stab: > > On Dec 19, 11:16 am, "Cathy Young" <[EMAIL PROTECTED]> wrote: > > I'm having trouble with generating a QuerySet using a reverse > > ForeignKey lookup, and I'm not sure why I'm getting an error. > > > > Here is my model, with only the relevant attributes shown: > > > > def EntryStatus(models.Model): > > ... > > user = models.ForeignKey(User) > > entry = models.ForeignKey(Entry) > > > > where Entry is another of my models and User is Django's own. > > > > I want a QuerySet of Entry objects from a specific user, so I have > > tried the following but received an AttributeError: > > > > >>> Entry.objects.filter(entrystatus__user=3) > > (large traceback...) > > File "D:\Program Files\Python > > 2.4.1\lib\site-packages\django\db\models\query.py", line 873, in > > lookup_inner > > column = field.column > > AttributeError: 'RelatedObject' object has no attribute 'column' > > > > Can anyone shed light on this and/or tell me what I should be doing > > instead? > > Since the "user" object at the other end isn't an int, maybe you need > something like: > > >>> Entry.objects.filter(entrystatus__user__pk=3)
Aha! This does work, though I'm still confused about why my previous try didn't, since I can specify "user=3" in other places and it looks up the primary key automatically. Thanks for your help, Chris! -- Cathy http://www.bentbacktulips.co.uk/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---