我有一个这样的表格:
account_type_choices = ('1234', '1234567')
choice_field = forms.ChoiceField(widget=forms.RadioSelect, choices=account_type_choices)
# In templates shown like this
[li] [radio_button] 2
[li] [radio_button] 2
怎么了?
答案 0 :(得分:0)
choices
需要是一系列2元组。像这样:
ACCOUNT_TYPE_CHOICES = (('1234', '1234'), ('1234567', '1234567'))
(另请注意,通常将名称放在所有大写字母中,因为它是常量。)