3👍
There was no need to do a landing_validation view this line solved the issue.
url(r'^$', LoginView.as_view(template_name='landing.html'), name='landing')
2👍
The login
function that you’re using is not actually a view. It’s just a regular function which you can use to authenticate a user and set the session cookie, etc.
Read the docs for it’s usage: https://docs.djangoproject.com/en/2.2/topics/auth/default/#django.contrib.auth.login
Judging by your code, it appears you want to use LoginView
.
from django.contrib.auth.views import LoginView
def landing_validation(request):
login_response = LoginView.as_view()(request, template_name='landing.html')
return login_response
2👍
In Django 2.2 app I fixed similar error by using LoginView
instead of login
.
File users/urls.py:
from django.conf.urls import url
# from django.contrib.auth.views import login
from django.contrib.auth.views import LoginView
from . import views
app_name = 'users'
urlpatterns = [
# url(r'^login/$', login, {'template_name': 'users/login.html'}, name='login'),
url(r'^login/$', LoginView.as_view(template_name='users/login.html'), name='login'),
]
1👍
You can see that django.contrib.auth.login takes request, user, and an optional backend. There is no template_name. This hasn’t changed recently, so I think you would get the same problem in 1.11, too.
It looks like you want a view function, but django.contrib.auth.login is not that. It doesn’t return a response.
- [Django]-Django compare query with F objects adds extra not null check
- [Django]-Django mssql setup : error initializing DB
- [Django]-Django-compressor + less compress the files but link to original files
- [Django]-Adding new form fields dynamically in admin
- [Django]-Gunicorn not running can't connect to sock file