Created 2 forms on the test site - registration and authorization. For example, if in the registration form you skip some field, then an error is displayed that you need to fill in the field. If you make a mistake in the authorization field, the page is simply updated with the fields reset. Both forms function correctly. Django 1.9.7
from django.shortcuts import render, redirect from django.contrib.auth import authenticate, login, logout from django.contrib.auth.forms import UserCreationForm, AuthenticationForm from .models import Post def auth(request): if request.user.is_authenticated(): return redirect('/') elif request.method == 'POST': form_auth = AuthenticationForm(request.POST) username, password = request.POST.get('username', ''), request.POST.get('password', '') user = authenticate(username=username, password=password) if user is not None: login(request, user) return redirect("/") else: form_auth = AuthenticationForm() return render(request, "blog/auth.html", {'form_auth': form_auth}) def reg(request): if request.user.is_authenticated(): return redirect('/') elif request.method == 'POST': form_reg = UserCreationForm(request.POST) if form_reg.is_valid(): new_user = form_reg.save() return redirect('/auth/') else: form_reg = UserCreationForm() return render(request, "blog/reg.html", {'form_reg': form_reg})