Opened 18 years ago

Closed 16 years ago

#2400 closed enhancement (fixed)

allow querying of existance of backwards relationship without resorting to custom sql

Reported by: mattimustang@… Owned by: nobody
Component: Core (Other) Version: dev
Severity: normal Keywords: qs-rf-fixed
Cc: mattimustang@…, tyson@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Both of these threads cover the same issue:

http://groups.google.com/group/django-users/browse_frm/thread/98b7aedf8f9d806c

http://groups.google.com/group/django-users/browse_frm/thread/b129d64b1ed77e28

To summarize, I can get all Reporters who have associated Articles by doing:

        Reporter.objects.filter(article__isnull = False) 

But, I can't get Reporters who have *no* associated Article by doing:

        Reporter.objects.filter(article__isnull = True) 

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

Furthermore, being able to do the same in limit_choices_to would be extremely useful.

Change History (7)

comment:1 by Tyson Tate <tyson@…>, 18 years ago

Cc: tyson@… added

+1 Would be useful. Sign me up for this one.

comment:2 by Malcolm Tredinnick, 17 years ago

Owner: changed from Adrian Holovaty to Malcolm Tredinnick

comment:3 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Nis Jørgensen <nis@…>, 17 years ago

Keywords: qs-rf added

comment:5 by Malcolm Tredinnick, 16 years ago

(In [6503]) queryset-refactor: Added a test to show we can now query for empty reverse
relationships. Refs #2400.

comment:6 by Malcolm Tredinnick, 16 years ago

Keywords: qs-rf-fixed added; qs-rf removed

comment:7 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

(In [7477]) Merged the queryset-refactor branch into trunk.

This is a big internal change, but mostly backwards compatible with existing
code. Also adds a couple of new features.

Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658

Note: See TracTickets for help on using tickets.
Back to Top