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 [email protected] 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 -~----------~----~----~----~------~----~------~--~---

