Answer the question
In order to leave comments, you need to log in
How to do user authorization in django?
Wrote authorization using guides
def auth(request):
if request.user.is_authenticated():
return redirect('account/')
elif request.method == 'POST':
form_auth = AuthenticationForm(request=request, data=request.POST)
if form_auth.is_valid():
user = form_auth.get_user()
AUTH.login(request, user)
return redirect("account/")
else:
form_auth = AuthenticationForm()
return render(request, "lk/auth.html", {'form_auth': form_auth})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question