On Tuesday, July 30, 2013 6:26:47 PM UTC+3, Daniele Procida wrote:
>
> On Mon, Jul 29, 2013, akaariai wrote:
>
> >> I understood that part. But by "more general" I mean one that will work
> >> for any case, without having to know where the Nulls might be.
> >>
> >> So
On Mon, Jul 29, 2013, akaariai wrote:
>> I understood that part. But by "more general" I mean one that will work
>> for any case, without having to know where the Nulls might be.
>>
>> So given queryset A, and its subset queryset B, we can place B against A
>> and obtain
On Sunday, July 28, 2013 10:44:49 AM UTC+3, Daniele Procida wrote:
>
> On Sat, Jul 27, 2013, Steve McConville
> wrote:
>
> >Perhaps I'm not sure exactly what you mean by "more general", but I
> >was recommending something like
> >
> >red_things =
On Sat, Jul 27, 2013, Steve McConville wrote:
>Perhaps I'm not sure exactly what you mean by "more general", but I
>was recommending something like
>
>red_things = queryset.filter(Q(color="red"))
>non_red_things = queryset.filter(~Q(color="red") |
Perhaps I'm not sure exactly what you mean by "more general", but I
was recommending something like
red_things = queryset.filter(Q(color="red"))
non_red_things = queryset.filter(~Q(color="red") | Q(color__isnull=True)
This will produce SQL like
SELECT * FROM queryset WHERE color IS 'red';
On Fri, Jul 26, 2013, Steve McConville wrote:
>> 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?
>
>As I understand it, this is correct -
On Fri, Jul 26, 2013, Bill Freeman wrote:
>You really should figure out which record isn't showing up in either sub
>case and look at it in detail to see if NULLs are involved before you spend
>time trying to fix a problem that you don't have.
>
>You could, for example collect
> 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?
As I understand it, this is correct - it's certainly the way SQL was designed.
> In that case, is there a better - more
You really should figure out which record isn't showing up in either sub
case and look at it in detail to see if NULLs are involved before you spend
time trying to fix a problem that you don't have.
You could, for example collect all the ids from the several queries into
python sets, union the
On Fri, Jul 26, 2013, Steve McConville 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
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). Secondly
SQL uses a 3-valued logic (with null) so if any of the fields you're
filtering on are
How is this possible?
# we start with a queryset actual_events
# get forthcoming_events using filter()
forthcoming_events = actual_events.filter(
Q(single_day_event = True, date__gte = datetime.now()) | \
Q(single_day_event = False, end_date__gte = datetime.now())
)
# get
12 matches
Mail list logo