Opened 6 years ago

Last modified 6 years ago

#30076 closed Bug

get_FOO_display missing if field choices is specified but falsey — at Version 4

Reported by: Joshua Cannon Owned by: Joshua Cannon
Component: Database layer (models, ORM) Version: 2.1
Severity: Normal Keywords: choices get_FOO_display
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Joshua Cannon)

Since Field checks if choices is truthy code instead of checking against None, some model instances aren't receiving the get_FOO_display method.

Usually the culprit is Field subclasses doing some kind of dynamic choice generation, providing choices=() as a sort of fallback. Since () is an empty tuple that is falsy, the method never gets added.

So far I've seen 2 libraries that have this "issue", which is likely a small set.

Change History (4)

comment:1 by Joshua Cannon, 6 years ago

Owner: changed from nobody to Joshua Cannon

comment:2 by Simon Charette, 6 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Joshua Cannon, 6 years ago

Has patch: set

comment:4 by Joshua Cannon, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top