In a Django form, how do I make a field read-only (or disabled)?
When the form is being used to create a new entry, all fields should be enabled - but when the recor
You can elegantly add readonly in the widget:
class SurveyModaForm(forms.ModelForm): class Meta: model = Survey fields = ['question_no'] widgets = { 'question_no':forms.NumberInput(attrs={'class':'form-control','readonly':True}), }