Answer the question
In order to leave comments, you need to log in
How to do django authorization?
Authorisation Error. When I authorize in the adminpanel through the super user, the username is displayed. and when I try to log in through a registered user (not in the adminpanel), it does not work.
html
url.py
from django.conf.urls import url
from . import views
from django.conf import settings
from django.contrib.auth.views import logout
urlpatterns = [
url(r'^index/$', views.index, name='index'),
url(r'^login/$', views.login, name='login'),
url(r'^registration/$', views.registration, name='registration'),
url(r'^logout/$', logout, {'next_page': "/main/login"}, name='logout')
]
def login(request):
template = "main/login.html"
params = dict()
if request.method == "POST":
email = request.POST.get("email", "")
password = request.POST.get("password", "")
print email
print password
user = authenticate(username=email, password=password)
print user
if user is None:
print 1
template = "main/index.html"
return render(request, template, params)
return render(request, template, params)
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