Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#12105 closed (fixed)

Admin querystring __isnull=False filter doesn't work

Reported by: marcob Owned by: gabrielhurley
Component: contrib.admin Version: 1.1
Severity: Keywords: isnull filter
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by Alex)

If I use __isnull=False with an admin querystring filter I always get a IS NULL query.
Try with:

   http://127.0.0.1:8000/admin/auth/user/?email__isnull=False

   http://127.0.0.1:8000/admin/auth/user/?email__isnull=True

You'll get same results.
I fixed with a tiny patch (attached):

            elif key.endswith('__isnull'):
                value = False if value.lower() == 'false' else Tru

Attachments (2)

isnull_false_filter.patch (689 bytes) - added by marcob 4 years ago.
12105-r11858.diff (2.5 KB) - added by Travis Cline <travis.cline@…> 4 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 4 years ago by Alex

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 4 years ago by jacob

  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 4 years ago by SmileyChris

  • Needs tests set
  • Patch needs improvement set

Inline if isn't a feature of Python 2.4

comment:4 Changed 4 years ago by marcob

Better patch. It doesn't use inline and it keep working a previous workaround ( isnull= with a null value )

    http://127.0.0.1:8000/admin/auth/user/?email__isnull=

Changed 4 years ago by marcob

comment:5 in reply to: ↑ description Changed 4 years ago by mikepenn

  • Owner changed from nobody to mikepenn

Replying to marcob:

If I use __isnull=False with an admin querystring filter I always get a IS NULL query.
Try with:

   http://127.0.0.1:8000/admin/auth/user/?email__isnull=False

   http://127.0.0.1:8000/admin/auth/user/?email__isnull=True

You'll get same results.
I fixed with a tiny patch (attached):

            elif key.endswith('__isnull'):
                value = False if value.lower() == 'false' else Tru

Changed 4 years ago by Travis Cline <travis.cline@…>

comment:6 Changed 4 years ago by Travis Cline <travis.cline@…>

  • Needs tests unset
  • Patch needs improvement unset

comment:7 Changed 4 years ago by mikepenn

  • Needs tests set
  • Owner mikepenn deleted
  • Patch needs improvement set

comment:8 Changed 4 years ago by mikepenn

  • Needs tests unset
  • Patch needs improvement unset

comment:9 Changed 4 years ago by gabrielhurley

  • Owner set to gabrielhurley
  • Status changed from new to assigned

Travis' patch looks good to me... seems like this one's in the bag. If anyone spots anything else about it I'll wrap it up.

comment:10 Changed 4 years ago by kmtracey

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

(In [12795]) Fixed #12105: Corrected handling of isnull=False lookups in admin. Thanks marcob, Travis Cline, gabrielhurley.

comment:11 Changed 4 years ago by kmtracey

(In [12796]) [1.1.X] Fixed #12105: Corrected handling of isnull=False lookups in admin. Thanks marcob, Travis Cline, gabrielhurley.

r12795 backport from trunk.

comment:12 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.