Ah, most enlightening and makes perfect sense, thanks Tom! ? 11 ?.?. 2553 ???? 21:45 Tom Evans <tevans...@googlemail.com> ?????:
> 2010/10/11 Jonathan Barratt <jonathan.barr...@knifeict.com>: >> On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote: >> Note also that, AFAIK, multiple where criteria are accomplished by chaining >> filters rather than providing them as a list to one filter call. >> But I am new to Django myself, so if anyone corrects this advice - follow >> their directions not mine! :) > > That's not quite right, both are suitable (and _can_ have different > meanings, although not in this case). > > If you assume models like so: > > class Item: > name = CharField > type = ManyToManyField('Type') > > class Type: > name = CharField > enabled = BooleanField > displayable = BooleanField > > then these two lines are different query sets: > > Item.objects.filter(type__enabled=True, type__displayable=True) > > Item.objects.filter(type__enabled=True).filter(type__displayable=True) > > > The former selects Items with one or more associated Type instances > that are both enabled and displayable. The latter selects Items that > have one or more associated Type instances that are enabled and > displayable, but not necessarily the on the same Type object. > > When the filter is not over a m2m field though, the two forms are > largely equivalent. > > For more info see the manual: > > http://docs.djangoproject.com/en/1.2/topics/db/queries/#spanning-multi-valued-relationships > > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.