Opened 9 years ago

Closed 7 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: master
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: UI/UX:

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 Changed 9 years ago by Tyson Tate <tyson@…>

  • Cc tyson@… added

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

comment:2 Changed 9 years ago by mtredinnick

  • Owner changed from adrian to mtredinnick

comment:3 Changed 8 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 8 years ago by Nis Jørgensen <nis@…>

  • Keywords qs-rf added

comment:5 Changed 8 years ago by mtredinnick

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

comment:6 Changed 8 years ago by mtredinnick

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

comment:7 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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