Hi all,

I have a question about reverse queries in ForeignKey relationships. Taking 
the example given in 
<http://www.djangoproject.com/documentation/models/many_to_one/>, I know that 
I can filter the Reporter objects to get those who have associated Articles, 
based on Article properties:

        Reporter.objects.filter(article__headline__startswith='This')

I guess I can get all Reporters who have associated Articles by doing:
        
        Reporter.objects.filter(article__isnull = False)


But, is there a way to get Reporters who have *no* associated Article? I tried

        Reporter.objects.filter(article__isnull = True)

but it returns an empty list, since the article property does not exist for 
those Reporters, and thus, it can't even be null. 

The aim is to use this in a limit_choices_to option, to only allow selection 
of 'free' Reporters in the admin interface (ie. Reporters who still do not 
have written any article, they lazy guys).

TIA,
-- 
Kilian CAVALOTTI                      Administrateur réseaux et systèmes
UPMC / CNRS - LIP6 (C870)
8, rue du Capitaine Scott                          Tel. : 01 44 27 88 54
75015 Paris - France                               Fax. : 01 44 27 70 00

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to