Reputation: 6107
I need to check if a form field is disabled in the template. The field is disabled depending on some other factors but I've simplified it below.
class MyForm(forms.Form):
quantity = forms.IntegerField()
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['quantity'].disabled = True
Then in the template I'd like to do something like this:
{% if form.quantity.disabled is True %}
...
{% endif %}
Upvotes: 1
Views: 554