Friday, July 26, 2013

Re: .filter() and .exclude() don't add up

On Fri, Jul 26, 2013, Steve McConville <mcconville.steve@gmail.com> wrote:

>Firstly (and I don't think this is the cause of the problem) you're
>calling datetime.now() four times, which will give you four different
>datetimes (ie. the queries will not be completely identical).

Good point, I will address that.

> Secondly
>SQL uses a 3-valued logic (with null) so if any of the fields you're
>filtering on are nullable you may not be able to rely on the law of
>the excluded middle

So, if one of the fields can be Null, then *neither*:

queryset.filter(field=value)

queryset.exclude(field=value)

will match a record where it's Null?

In that case, is there a better - more reliable - way than using both .filter() and .exclude() with the same terms to split a queryset into all those items that match a filter, and all those that don't?

Thanks,

Daniele

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate