Opened 3 years ago

Closed 3 years ago

#17629 closed Bug (invalid)

forms.ChoiceField throws TypeError if label argument not provided

Reported by: pydanny 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)

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 3 years ago by Alex

  • 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 3 years ago by Alex

  • Resolution set to invalid
  • Status changed from new to closed

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