4👍
Hey looks like you are using the wrong django version, django.contrib.auth.views.logout
is not available in your current django version, try downgrading your django version to a lower version with this command:
sudo pip install Django==2.0.2
or change the import in order to use logout_view
27👍
ImportError: cannot import name 'login' from 'django.contrib.auth.views'
I had this error and looked up for a solution found it here. Remove views from import
Works for me in Python 3.7 and Django 2.2. No need to downgrade to Django 2.0.4(as LTS is in 2.2)
It was this one that caused me the error.
from django.contrib.auth.views import login
Had to change it to
from django.contrib.auth import login
Worked for logout too.
3👍
settings.py
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
urls.py
from django.conf.urls import url
from django.contrib.auth.views import LogoutView
urlpatterns = [
url(r'^logout$', LogoutView.as_view(), name='logout'),
]
it’s work for me on django 3.0.x
- What is the different between the get logger functions from celery.utils.log and logging?
- Determine empty template variable in Django
- Django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed
- Why django uses a comma as decimal separator
- Django admin, extending admin with custom views
2👍
this is for django 2.x
, docs
from django.contrib.auth import logout
def logout_view(request):
logout(request)
# Redirect to a success page.
- How to change django datetime format output?
- How to filter filter_horizontal in Django admin?
- Why is post_save being raised twice during the save of a Django model?
0👍
This is the code I added to urls.py
to get login working:
def my_logout(request):
logout(request)
return redirect('index')
along with urlpatterns
:
path('logout/', my_logout, name="logout"),
Works for me in Python 2.7, Django 2.1.5!
- Django DEBUG=False still runs in debug mode
- Suppress "field should be unique" error in Django REST framework
- Git aws.push: No module named boto
0👍
In the latest version of Django (django == 3.2.4) the import should be the following
from django.contrb.auth.views import LogoutView
- How to load sql fixture in Django for User model?
- Pass list of fields to QuerySet.values( )
- Assign Value of Named URL to a Variable in Django Templates
- Found another file with the destination path – where is that other file?
- Best practices for preventing Denial of Service Attack in Django
-1👍
Pyhton is very case sensitive… make sure your code lines up with proper whitespace. I go this error and make functions created in views.py were not aligned
- How to Test Stripe Webhooks with Mock Data
- Validation on query_params in Django Rest Framework
- How to change the 'tag' when logging to syslog from 'Unknown'?
- Django admin inline: select_related
- How to display human time (x days ago, or now) in django admin?