Customizing UserCreationForm
UserCreationForm
currently shows quite a lot of additional help text (included by default) that is cluttering our form. To remedy this, we can customize UserCreationForm
(which is a big topic on its own). Here, we will apply some simple modifications to improve the look and feel of our signup page.
To implement these modifications, we will follow these steps:
- Create
CustomUserCreationForm
. - Update the
signup
function to useCustomUserCreationForm
. - Customize the way errors are displayed.
We will undertake each of these steps in detail in the next few subsections.
Creating CustomUserCreationForm
In /accounts/
, create a new file called forms.py
. This file will contain the custom forms of the accounts app. For now, fill it in with the following code:
from django.contrib.auth.forms import UserCreationForm class CustomUserCreationForm(UserCreationForm): def __init__(self, *args, **kwargs): ...