BooleanField should not override 'blank' if choices are specified
|Reported by:||Jonas H.||Owned by:||Tushar Bhatia|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||jonas-django@…, tushar747@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
BooleanField currently allows settings 'choices'. It also always overrides 'blank'. This stems from the fact that in HTML, a blank value means False, and any (?) non-blank value means True for check boxes.
Now if you override 'choices', things change in terms of HTML, since now True and False are represented by "True" and "False" in the select box. This also makes it possible to supply a null/blank value (which would have meant False in the checkbox case).
BooleanField should either handle this fact gracefully, for instance by only overriding 'blank' if 'choices' is not given and then interpreting "True" and "False" as True and False. Or it should disallow overriding 'choices' entirely.
Change History (22)
comment:7 Changed 2 years ago by
|Summary:||BooleanField should either forbid setting 'choices' or not override 'blank' → BooleanField should not override 'blank' if choices are specified|
|Triage Stage:||Unreviewed → Accepted|