Opened 4 years ago

Closed 4 years ago

#15977 closed Bug (needsinfo)

ChoiceField breaks if value is None

Reported by: adam@… Owned by: nobody
Component: Forms Version: 1.3
Severity: Normal Keywords: form clean validate
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX:

Description

https://github.com/django/django/blob/master/django/forms/fields.py#L676

If the value of a ChoiceField is None (ie. it was set programmatically from something other than an HTML request and that value was not entered) then this will throw a TypeError instead of creating a proper ValidationError. Perhaps change it to "{'value':value or 'None'}" to avoid this?

Change History (1)

comment:1 Changed 4 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

Please provide at least a snippet of code to demonstrate the problem. It is not obvious when looking at the fields.py code.

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