0
I’m having trouble making one Choice Yeah, when he goes by form
, the field
returns only ""
or None
. Already if I put widget=RadioSelect
, it returns the correct numbering.
Model:
ORDER_CHOICES = (
(1, "1° Prêmio"),
(2, "2° Prêmio"),
(3, "3° Prêmio"),
(4, "4° Prêmio"),
(5, "5° Prêmio"),
)
order = models.IntegerField(
'Premiação', choices=ORDER_CHOICES,
db_column='order', blank=True)
Forms:
class Selectpremiumform(Forms.Modelform):
order = forms.ChoiceField(choices=SelectPremium.ORDER_CHOICES,
widget=forms.RadioSelect)
class Meta:
model = SelectPremium
fields = ['order']
Leonardo, I do not understand very well what you intend to do, but if it is to present a combobox with the options of ORDER_CHOICES, you can just reference your Model in the Form as it has been done that it appears without needing to write it again, ie the line
order = forms.ChoiceField(choices=SelectPremium.ORDER_CHOICES, widget=forms.RadioSelect)
can be deleted. From what I have tested here, it is rendering normally in html... you can edit your question to be clearer?– Carlos Cortez
Yes in Radio works normally, puts in Select not only saved renderia, does not validate the field always comes blank. I wanted to use in Select mode which would be the Default of Choice. But unfortunately it does not come given any.
– Leonardo Graciano