1.

How to Create User Sign Up View

Answer»

A simple way to CREATE a user sign up is by using the UserCreationForm.  Django provides a form 'UserCreationForm' inherited from ModelForm CLASS to HANDLE new user creation. The user creation form has three fields username, password1, and password2. Password2 is for password confirmation.

First, you have to import UserCreationForm to use it from django.contrib.auth.forms import UserCreationForm To handle the creation of users, Django does not provide any view, we have to create our own view.

So proceeding further to create user, here we are using project myproject and application myapp. To create user fist update urlpattern at the beginning of the URLPATTERNS list. Then create a new function in views.py to authenticate and save the user. The last step is to create an HTML template for the form display(view).

The User created, using 'UserCreationForm will have is_superuser and is_staff flag set to FALSE but is_active flag set to True. UserCreationForm does not have an email field, so we can't email verification to the user to verify the account.



Discussion

No Comment Found