2
The documentation of ChoiceField states:
- Empty value:
''
(an empty string)- Normalizes to: A Unicode object.
In fact, invalid literal for int() with base 10: ” is the result of calling int
on an empty string.
What you want to use is a TypedChoiceField:
- Empty value: Whatever you’ve given as
empty_value
- Normalizes to: A value of the type provided by the
coerce
argument.
In your case, you should use TypedChoiceField the same way you were using ChoiceField, except that you should also add the empty_value=0
parameter.
Source:stackexchange.com