Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#9177 closed (duplicate)

list_filter cannot filter nullable fields

Reported by: Bob Thomas Owned by: nobody
Component: contrib.admin Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a model with a FloatField that is nullable. I would like to filter models that have that field set to null, so I added it to list_filter in my ModelAdmin class. When I select the "None" option, I get an exception from get_db_prep_value because it's calling float(None). I tried modifying get_db_prep_value for FloatField to return None if value is None or "None", which got rid of the exception, but did not return any results.

Will attach a patch if I figure out how to fix this to return correct results.

ForeignKey fields that are nullable do not even display a None option in the filter, but I get a similar error trying to modify the query string to use None instead of an id.

Change History (2)

comment:1 by Matt McClanahan, 16 years ago

Resolution: duplicate
Status: newclosed

Dup of #8528

comment:2 by Bob Thomas, 16 years ago

My main complaint here was that there is a "None" option displayed which raises an exception when clicked, so it's not really the same as #8528, which is asking for the addition of a none/null option. I attached a patch to that ticket that fixes this, though.

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