#16291 closed Cleanup/optimization (fixed)
Document that TypedChoiceField does not coerce empty_value
Reported by: | Klaas van Schelven | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Taavi Taijala | 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
When the empty value is selected in a TypedChoiceField this is not passed through the coerce function.
I suppose this is what could be deduced from the existence of the empty_value parameter, but it was very surprising to me indeed.
Current description here:
https://docs.djangoproject.com/en/dev/ref/forms/fields/#typedchoicefield
My personal feeling would be to send all values through coerce, but I suppose the alternative would be to simply document this behavior more explicitly.
Attachments (1)
Change History (7)
comment:1 by , 13 years ago
Component: | Uncategorized → Documentation |
---|---|
Summary: | TypedChoiceField does not coerce "" value, uses empty_value instead → Document that TypedChoiceField does not coerce empty_value |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 13 years ago
Has patch: | set |
---|---|
Triage Stage: | Accepted → Ready for checkin |
I added a patch that clarifies the documentation. If there's anything else that needs to be added, please change the Triage Stage back to Accepted and let me know.
comment:3 by , 13 years ago
Cc: | added |
---|
follow-up: 6 comment:4 by , 13 years ago
Thank you for your patch.
Just a note on the process. As mentioned in a few places in the contributing guide (for example, at the bottom of [1]
), one should not promote their own patch to RFC and instead let someone else review the patch first. Then the ticket can be moved by that person to RFC otherwise comments can be left telling how the patch should be improved.
In this case, the patch looks good so I'm leaving the ticket in RFC. Don't hesitate to check out the contributing guide for more info on how to deal with future tickets. Cheers!
[1]
https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/
comment:6 by , 13 years ago
Replying to julien:
Thank you for your patch.
Just a note on the process. As mentioned in a few places in the contributing guide (for example, at the bottom of
[1]
), one should not promote their own patch to RFC and instead let someone else review the patch first. Then the ticket can be moved by that person to RFC otherwise comments can be left telling how the patch should be improved.
In this case, the patch looks good so I'm leaving the ticket in RFC. Don't hesitate to check out the contributing guide for more info on how to deal with future tickets. Cheers!
[1]
https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/
Whoops. Sorry about that. I looked through the docs the other day, but I was just skimming them and I somehow missed that. Maybe that's something I should add to my tutorial for first time contributors. :-)
Coercing
empty_value
would be backwards-incompatible. Also, it is better practice and more pythonic for the developer to explicitly provide an already correctly-typed empty value if they wish to customise thecoerce
function. So it is a matter of clarifying the documentation to explain the current behaviour.