Ah yes, I know this. For some reason, however, user.class_set.all()
doesn't seem to be returning a queryset (I need to be using a queryset
so I can feed it into a modelChoiceField). Is there any way that I can
turn class_set.all() into a queryset?

On Aug 18, 6:14 am, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote:
> I seem to keep making this mistake, even though I know better.
>
> contains only works for strings. In other words, it checks to see if a
> string field contains the substring you provide. You want to use the
> reverse relationship from the user, rather than a query:
>
> myUser = User.objects.get(username='thisUsername')
> classes = myUser.class_set.all()
>
> Todd
>
> On Sun, Aug 17, 2008 at 8:11 PM, Robert <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
> > I'm trying to query a ManyToManyField to see whether or not it
> > contains a specific type of object.
> > My query is as follows:
> > MyUser = User.objects.get(username='thisUsername')
> > theQuery = Class.objects.filter(users__contains=myUser)
>
> > but when I try to run that, i get the following error:Related Field
> > has invalid lookup: contains
> > Any thoughts?
> > Thank you so much, any help is greatly appreciated.
> > -Robert
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to