Django

Code

Ticket #2400 (closed: fixed)

Opened 2 years ago

Last modified 3 weeks ago

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

Reported by: mattimustang@gmail.com Assigned to: nobody
Component: Core framework Version: SVN
Keywords: qs-rf-fixed Cc: mattimustang@gmail.com, tyson@fallingbullets.com
Triage Stage: Accepted Has patch: 0
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

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.

Attachments

Change History

07/22/06 11:49:19 changed by Tyson Tate <tyson@fallingbullets.com>

  • cc changed from mattimustang@gmail.com to mattimustang@gmail.com, tyson@fallingbullets.com.

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

09/26/06 20:19:35 changed by mtredinnick

  • owner changed from adrian to mtredinnick.

04/21/07 08:24:32 changed by Simon G. <dev@simon.net.nz>

  • stage changed from Unreviewed to Accepted.

09/14/07 09:07:19 changed by Nis Jørgensen <nis@superlativ.dk>

  • keywords set to qs-rf.

10/13/07 22:46:20 changed by mtredinnick

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

10/13/07 22:47:27 changed by mtredinnick

  • keywords changed from qs-rf to qs-rf-fixed.

04/26/08 21:50:16 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(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


Add/Change #2400 (allow querying of existance of backwards relationship without resorting to custom sql)




Change Properties
Action