THE USER REGISTRATION FORM CLASS
Let’s go immediately to create the form. We should use a ModelForm as there is already a user model in Django. The User object. This object contains several fields some of which are not necessary for a registration form. Let’s see the code.
In this case we have to validate two fields password and confirm_password, and the clean_field_name function is not good. We can use the clean() function for this purpose. I am now going to create the function in views.py which will use the form.
Once the User object has been created, we authenticate it and log in, before redirecting the user to the home page. Let’s see the registration template:
NB: Remember to register the view in urls.py. We run the development server and create a user. Once created you can see from the Django Admin panel that this user does not have staff privileges.
Leave A Comment