I'd like to create disabled field with ModelForm on django 1.11.
I read django has "disabled field options" since 1.9. However, I can not understand how do I define disabled field with ModelForm.
Could you tell me how to create disabled field with ModelForm please ?
Here is my models.py, forms.py and views.py
class my_model(models.Model)
name = models.CharField(max_length=10,)
title = models.CharField(max_length=10,)
date = models.DateField(default=date.today,)
def __str__(self):
return u'%s' % (self.name)
class my_modelform(ModelForm):
class Meta:
model = my_model
fields = ['name', 'title', 'date']
widgets = {
'date': DateWidget(usel10n=True, bootstrap_version=3,),
}
disabled = [ 'name' ]
class my_UpdateView(UpdateView):
model = my_model
form_class = my_modelform
template_name = "update_form.html"
success_url = "success.html"
Although, I changed the "disabled = {'name' : True} instead of [ 'name' ], it doesn't work.