First [[Implement a basic sign up feature]], we can customize fields of UserCreationForm by creating a new class that extends UserCreationForm
.
create a new file forms.py
and fill it with the following:
from django.contrib.auth.forms import UserCreationForm
class UserCreateForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super(UserCreateForm, self).__init__(*args, **kwargs)
for fieldname in ('username', 'password1', 'password2'):
self.fields[fieldname].help_text = None
self.fields[fieldname].widget.attrs.update(
{'class': 'form-control'}
)
We replace all UserCreationForm
with this new UserCreateForm
in views.py.