1👍
✅
You really should do this in the declaration of your ExampleForm class. I assume the class looks something like this
from your_app.models import ExampleModel
from django.forms import ModelForm
class ExampleForm(ModelForm):
class Meta:
model = ExampleModel
You just need to declare the field on the form. Something like –
class ExampleForm(ModelForm)
is_ok = forms.BooleanField()
class Meta:
model = ExampleModel
The form class will now handle the creation of the input
element for the is_ok
field, just as it does for all the other fields, but it will override the settings on the Model – it won’t be disabled any more (see the docs for more info).
Source:stackexchange.com