Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#12105 closed (fixed)

Admin querystring __isnull=False filter doesn't work

Reported by: marcob Owned by: Gabriel Hurley
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 Gaynor)

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 7 years ago.
12105-r11858.diff (2.5 KB) - added by Travis Cline <travis.cline@…> 7 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 7 years ago by Alex Gaynor

Description: modified (diff)

comment:2 Changed 7 years ago by Jacob

milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:3 Changed 7 years ago by Chris Beaven

Needs tests: set
Patch needs improvement: set

Inline if isn't a feature of Python 2.4

comment:4 Changed 7 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 7 years ago by marcob

Attachment: isnull_false_filter.patch added

comment:5 in reply to:  description Changed 7 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 7 years ago by Travis Cline <travis.cline@…>

Attachment: 12105-r11858.diff added

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

Needs tests: unset
Patch needs improvement: unset

comment:7 Changed 7 years ago by mikepenn

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

comment:8 Changed 7 years ago by mikepenn

Needs tests: unset
Patch needs improvement: unset

comment:9 Changed 7 years ago by Gabriel Hurley

Owner: set to Gabriel Hurley
Status: newassigned

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 7 years ago by Karen Tracey

Resolution: fixed
Status: assignedclosed

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

comment:11 Changed 7 years ago by Karen Tracey

(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 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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