Improving the signup page to handle POST actions
When a user submits the signup form, we will have to handle the request and create a user in admin. To implement this, we will modify the signup
function.
In /accounts/views.py
, add the following lines that are in bold:
from django.shortcuts import render from django.contrib.auth.forms import UserCreationForm from django.shortcuts import redirect def signup(request): template_data = {} template_data['title'] = 'Sign Up' if request.method == 'GET': template_data['form'] = UserCreationForm() return render(request, 'accounts/signup.html', {'template_data': template_data}) elif request.method == 'POST':...