As per understanding with your code .
You are doing wrong at
if user.is_active and user.is_superuser: return HttpResponseRedirect('/admin/') elif user.is_active: login(self.request, user)
when you are trying to login code always go to if statement that's why it is redirecting to /admin/ but not making login actually.
Your code should be like
if user.is_active and user.is_superuser: login(self.request, user) # you must put login here and it will work fine return HttpResponseRedirect('/admin/') elif user.is_active: login(self.request, user)