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
Làm cách nào để tạo trường one_or_two chỉ đọc?Cách tạo ChoiceField chỉ đọc ở dạng django
Bạn đã thử xem nội dung này chưa? http://stackoverflow.com/questions/324477/in-a-django-form-how-to-make-a-field-readonly-or-disabled-so-that-it-cannot-b – Amit
Có, nó không 't làm việc cho tôi. Tôi đang mở rộng forms.Form không giống như ModelForm như trong câu hỏi nhọn. – Nullpoet