Hi, all. I realize I'm late getting in on this discussion, but... On 10/11/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > Choice.objects.filter(poll__pk=None) > > returns all Choice objects in the database, because any query where > value=None is outright ignored - no error, no warning. As a side note, > this also means that: >
There is some value in this when, for example, querying for objects where query parameters may be set by optional form elements. Say I've got a "Search for Restaurants" form with a checkbox for "Has boat dock" and a text input for "Limit to city". I can do Restaraunt.objects.filter(city__pk=city, boat_dock__exact=boat_dock) where city and boat_dock were just picked up from the GET dictionary or set to None if not present. With really large forms, having this use of None can make the lookup simple. Just lookup for all possible parameters, knowing that any unused parameters will be set to None and safely ignored. We used this several times at Naples News while I was there. I always assumed, perhaps incorrectly :-), that this use of None was intentional. Cheers, deryck -- Deryck Hodge http://www.devurandom.org/ Samba Team http://www.samba.org/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" 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-developers -~----------~----~----~----~------~----~------~--~---
