django logout redirects me to administration page

前端 未结 11 2132
生来不讨喜
生来不讨喜 2020-12-14 14:32

I have provided a simple login functionality. For logout, I tried to use the built-in one. This is my urls.py:

(r\'\', include(\'django.contrib.auth.urls\'))         


        
11条回答
  •  难免孤独
    2020-12-14 15:34

    This is all fairly well explained in the manual, is there anything specific you don't understand?

    https://docs.djangoproject.com/en/dev/topics/auth/default/#how-to-log-a-user-out

    from django.contrib.auth import logout
    
    def logout_view(request):
        logout(request)
        # Redirect to a success page.
    

    Alternatively if you don't want to create your own view

    https://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.views.logout

    {% url 'logout' next='/some/url/' %}
    

提交回复
热议问题