Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#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)

patch.diff (583 bytes ) - added by Taavi Taijala 13 years ago.
Clarifies the documentation

Download all attachments as: .zip

Change History (7)

comment:1 by Julien Phalip, 13 years ago

Component: UncategorizedDocumentation
Summary: TypedChoiceField does not coerce "" value, uses empty_value insteadDocument that TypedChoiceField does not coerce empty_value
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

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 the coerce function. So it is a matter of clarifying the documentation to explain the current behaviour.

by Taavi Taijala, 13 years ago

Attachment: patch.diff added

Clarifies the documentation

comment:2 by Taavi Taijala, 13 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin
Version 0, edited 13 years ago by Taavi Taijala (next)

comment:3 by Taavi Taijala, 13 years ago

Cc: Taavi Taijala added

comment:4 by Julien Phalip, 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:5 by Julien Phalip, 13 years ago

Resolution: fixed
Status: newclosed

In [16820]:

Fixed #16291 -- Documented that TypedChoiceField does not coerce empty_value. Thanks to vanschelven and taavi223.

in reply to:  4 comment:6 by Taavi Taijala, 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. :-)

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