python - How to logout in django? -


html code

{% if request.user %}     <a href="{% url 'main:logout' %}">         Выход     </a> {% else %}     <a href="{% url 'main:registration' %}">         Регистрация     </a> {% endif%}     

settings.py

login_redirect_url = 'main/index' 

views.py

def logout(request):     logout(request) 

urls.py

from django.conf.urls import url . import views django.conf import settings  urlpatterns = [     url(r'^logout/$', views.logout, {'next_page': settings.logout_redirect_url}, name='logout') ] 

what's wrong?

enter image description here

you using custom logout view doesn't take next_page parameter. should add parameter view , pass django logout call, or use django.contrib.auth.logout

e.g. in urls.py:

from django.conf.urls import url django.conf import settings django.contrib.auth.views import logout  urlpatterns = [     url(r'^logout/$', logout, {'next_page': settings.logout_redirect_url}, name='logout') ] 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -