Django model with models.Choices
class Special(models.Choices):
SPECIAL = (("welcome","My Welcome!"),
("privacy","my Privacy list"),
("happy","How happy you are"),
('',"-------------"))
and I have this code in form class
key_selector = forms.fields.ChoiceField(
choices = Special.SPECIAL
required=False,
widget=forms.widgets.Select
)
This error comes here
TypeError: 'Special' object is not iterable
How can I make the selectbox with django???
CodePudding user response:
key_selector = forms.fields.ChoiceField(
choices = Special.SPECIAL.choices
required=False,
widget=forms.widgets.Select
)
should work