Opened 12 years ago
Last modified 12 years ago
#20182 closed Bug
prepare_lookup_value should treat 0 as False for __isnull — at Initial Version
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | bmispelon@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
In contrib.admin.util, there is a prepare_lookup_value function
In this function, there is a clause
if value.lower() in (, 'false'):
value = False
I think it should be
if value.lower() in (, 'false', '0'):
value = False
Note that in admin already converts a limit_choices_to={'aisnull': False} to aisnull=0 when formatting a query string for lookup on the remote model. Therefore, clearly it should also handle isnull=0 correctly. Currently the lookup popup box on remote model uses isnull=0 and does not actually filter.
See the following pull request