5
class MyForm(forms.Form):
CHOICES = (('1', 'one',), ('2', 'two',))
one_or_two = forms.ChoiceField(widget=forms.RadioSelect, initial='1')
def show(request):
form = MyForm()
# render form
如何讓外地one_or_two只讀?如何使ChoiceField只讀Django的形式
你試過看這個嗎? http://stackoverflow.com/questions/324477/in-a-django-form-how-to-make-a-field-readonly-or-disabled-so-that-it-cannot-b – Amit
是的,它doesn不爲我工作。我正在擴展forms.Form,而不像ModelForm那樣在尖銳的問題中。 – Nullpoet