Re: "...where field is NULL" in Django ORM
Михаил Лукин wrote:
> For some reason, __exact and __isnull are described in documentation
> [1], while =None is not. So which of them are historical?
Django pre 1.0 generated bogus SQL, when doing nullable_field=None.
These days __isnull can be replaced by the expressions:
filter(foo__isnull=True) -> filter(foo=None)
filter(foo__isnull=False) -> exclude(foo=None)
Though I still use the __isnull lookup often as it's more explicit.
Besides I rarely use exclude(), so it feels more natural to have all
filter rules together in one statement.
You're right in one thing. The whole foo=value thing is not documented.
When looking at the QuerySet API it only shows the use of foo__exact. I
wonder if __exact is the default field lookup.
To be true I've never used __exact I always rely on the much less
verbose version.
--mp
--~--~---------~--~----~------------~-------~--~----~
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 django-users+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home