Django logout problem

后端 未结 5 1761
轻奢々
轻奢々 2021-02-09 08:05

Here is the problem I am facing with the Django Authenetication

  1. Access a page that requires a login.
  2. Logout (accessing django.contrib.auth.logout)
  3. <
5条回答
  •  既然无缘
    2021-02-09 08:28

    This worked for me. I was too stuck with this problem. Found the following solution on youtube.

    My solution is a little modified though.

    in views.py

    from django.contrib.auth import authenticate, login, logout
    from django.shortcuts import redirect
    
    def auth_logout(request):
      logout(request)
      return redirect('home')
    

    in urls.py

    url(r'^logout$', views.auth_logout, name='auth_logout'),  
    

提交回复
热议问题