Ivan Sagalaev wrote: > Gary Wilson wrote: > > Why can't objects be used in python sets? Example: > > > >>>> [u.username for u in User.objects.all()] > > ['bar', 'foo', 'foobar'] > >>>> a = User.objects.filter(username__contains='foo') > >>>> b = User.objects.filter(username__contains='bar') > >>>> set.intersection(set(a), set(b)) > > May be set(..) doesn't cause a queryset to actually evaluate... Try: > > set.intersection(set(list(a)), set(list(b)))
set() does eqvaluate the QuerySet: >>> set(a) set([<User: foobar>, <User: foo>]) >>> set(list(a)) set([<User: foobar>, <User: foo>]) >>> set(a) == set(list(a)) True --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---