开发者

Using Radio Button for boolean field in Modelform

开发者 https://www.devze.com 2023-03-29 13:31 出处:网络
in models choice = models.BooleanField() in forms I use choices = ( (\'1\', \'Buy\'), (\'0\', \'Sell\'), ) choice = forms.TypedChoiceField(label=u\'Тип предожения\', choices=choice

in models

choice = models.BooleanField()

in forms I use

choices = (
('1', 'Buy'),
('0', 'Sell'),

)

choice = forms.TypedChoiceField(label=u'Тип предожения', choices=choices, widget=forms.RadioSelect,)

but when i edit ite开发者_C百科m, value is not selected... How can I make to previous selected value be marked


You've used strings for your choices keys. Booleans are True and False.

0

精彩评论

暂无评论...
验证码 换一张
取 消