SHARE
TWEET

Untitled

a guest Oct 17th, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'AnonymousUser' object has no attribute '_meta'
  2.    
  3. def do_login(request):
  4.     """
  5.     Вьюха страницы авторизации
  6.     :param request: запрос
  7.     :return: рендер главной страницы при успешной авторизации / рендер логин страницы при неудаче
  8.     """
  9.  
  10.     if request.method == "POST":
  11.         form = LoginForm(request.POST)
  12.  
  13.         if form.is_valid():
  14.             username = form.cleaned_data.get('username')
  15.             password = form.cleaned_data.get('password')
  16.  
  17.             user = authenticate(username=username, password=password)
  18.  
  19.             auth.login(request, user)
  20.  
  21.             return HttpResponseRedirect('/')
  22.         else:
  23.             pass
  24.     else:
  25.         form = LoginForm()
  26.  
  27.     return render(request, 'cupper/login.html', {'form': form})
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top