Selecting 'Undecided' here results in the error message "'None' must be an
integer"
In order to fix this I have to add the following param to
TypedChoiceField:
{{{coerce=lambda v: int(v) if v and v != 'None' else None}}}
If I try this instead it results in the error "Select a valid choice. None
is not one of the available choices.":
{{{coerce=lambda v: int(v) if v else None}}}
It appears that the None choice is getting coerced to a string before it
passes into TypedChoiceField.to_python (or wherever it gets passed to
first)?
--
Ticket URL: <https://code.djangoproject.com/ticket/21224>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
This may be addressed in master (1.7) with #20649 - could you take a look
and see if that meets your use case?
--
Ticket URL: <https://code.djangoproject.com/ticket/21224#comment:1>
* status: new => closed
* resolution: => worksforme
Comment:
That change:
https://github.com/django/django/commit/1123f4551158b7fc65d3bd88c375a4517dcd0720
#diff-aee6730bae795d31efec3c5d014804a9R511
...should solve your issue, as the `None` choice will be rendered as the
empty string in the option value, then coercion should consider it as the
empty value. Reopen if you can reproduce an issue with master code.
--
Ticket URL: <https://code.djangoproject.com/ticket/21224#comment:2>