Django Forms How To Add Form Field Attribute
I'm using django-crispy-forms I want to add an attribute http-prefix to the outputted domain field, for example like this... Ho
Solution 1:
Simply update the attribute by setting the value to empty string:
def __init__(self, *args, **kwargs):
super(SchemeForm, self).__init__(*args, **kwargs)
#...
self.fields['domain'].widget.attrs['http-prefix'] = ''
Post a Comment for "Django Forms How To Add Form Field Attribute"