How to make ChoiceField read-only in django formats

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

How to make one_or_two field read- only?

+5
source share
1 answer

You can use the disabled attribute.

one_or_two = forms.ChoiceField(widget=forms.RadioSelect(attrs={'disabled': 'disabled'}), initial='1') 
+8
source

All Articles