I'm using Django Built-in forms, more precisely the PasswordChangeForm.
It works perfectly until the point where I want it to look like the rest of the website (Bootstrap). I followed the approach in this answer that is inheriting the class and built a new one by myself:
class PasswordChangeCustomForm(PasswordChangeForm):
old_password = CharField(required=True,
widget=PasswordInput(attrs={
'class': 'form-control'}))
new_password1 = CharField(required=True,
widget=PasswordInput(attrs={
'class': 'form-control'}))
new_password2 = CharField(required=True,
widget=PasswordInput(attrs={
'class': 'form-control'}))
But it annoys me to repeat all this code.
Is there another way to achieve the same thing (add the class form-control
to the each field) without re-writing each field?