Hi Phoebe,

I cannot reproduce this on Django's master branch. What version of Django 
are you using? It's possible it was fixed since then. Could you provide a 
minimal set of models to reproduce?

If upgrading to a more recent version of Djanago doesn't fix the problem, 
you might try .exclude(user__in= rather than .filter(~Q if that works for 
your query.

Tim

On Monday, November 11, 2013 6:36:12 AM UTC-5, Phoebe Bright wrote:
>
> I have this line in my code where the functions return an ID and what I 
> wanted was to select all records that did not belong to one of these users.
>
>     Carbon.objects.filter(~Q(user__in = [limbo_user(), system_user(), 
> retire_user()]))
>
> What I expected to get was 
>
> *SELECT* ••• <http://127.0.0.1:8000/dash/#> *FROM* "web_carbon" *WHERE* 
> *NOT*(("web_carbon"."user_id" *IN* (5, 2, 4))
>
> but what I actually got was
>
> *SELECT* ••• <http://127.0.0.1:8000/dash/#> *FROM* "web_carbon" *WHERE* 
> *NOT*(("web_carbon"."user_id" *IN* (5, 2, 4) *AND* "web_carbon"."user_id" 
> *IS**NOT NULL*)) 
>
> So it always returns a null set.  Is this correct behaviour and if so, 
> does anyone know what the correct syntax is?
>

-- 
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+unsubscr...@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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/be576720-2ccd-4123-bfc4-1a2e45acb8eb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to