/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def __init__(self, *args, **kwargs): super(form, self).__init__(*args, **kwargs) for field in self.errors: if not field == '__all__': # errors dict can have key __all__ for non field errors. self.fields[field].widget.attrs['class'] = \ self.fields[field].widget.attrs.get('class', '') + 'error'