Opened 5 years ago

Closed 5 years ago

#17629 closed Bug (invalid)

forms.ChoiceField throws TypeError if label argument not provided

Reported by: Daniel Greenfeld Owned by: nobody
Component: Forms Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Alex Gaynor)

GRID_TYPE_CHOICES = (("comparison", "Comparison"), ("gallery", "Gallery"))

  • grid_type = forms.ChoiceField(_("Type"), choices=(("comparison", "Comparison"), ("gallery", "Gallery")) # throws a TypeError.
  • grid_type = forms.ChoiceField(label=_("Type"), choices=GRID_TYPE_CHOICES) # Works fine

Change History (2)

comment:1 Changed 5 years ago by Alex Gaynor

Description: modified (diff)
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

Formatted for readability, please use preview in the future.

comment:2 Changed 5 years ago by Alex Gaynor

Resolution: invalid
Status: newclosed

This isn't a bug, the error you're seeing is probably "__init__ got multiple values for keyword argument 'choices'" , because choices is the first positional argument. You can't pass the label as a positional argument like that.

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