required_css_class apparently used by forms.BoundField.css_classes and forms.BaseForm._html_output , which is only for as_p , as_table , etc.
This is not part of the usual rendering of widgets.
You can use the same css_classes method to return classes for your element, so I think the easiest solution would be to wrap the <input> element and specify the class {{ field.css_classes }} and change your validation selector.
Alternatively, here you can crack the error class into error fields:
def __init__(self, *args, **kwargs): super(form, self).__init__(*args, **kwargs) for field in self.errors: if not field == '__all__':
To use required_css_class , you will need to use the BoundField.css_classes method, which includes hacking the __getitem__ and __iter__ base forms as the BoundField is created on demand. The above method is simpler.
source share