0
http://127.0.0.1:8000/accounts/login/

This page is created successfully and working nice:

And Problem with these pages: http://127.0.0.1:8000/accounts/logout/ This page redirect me Django Administration Pages that message to login again but I don't want this.

I have placed my HTML file in

..templates/registration/logged_out.html 

And checked spelling error multiple time to see why not working.

My urls files:

from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('catalog.urls')),
    path('accounts/', include('django.contrib.auth.urls')),
]

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

and my logged_out.html is:

{% extends 'base.html' %}


{% block content %}
  <p>Logged out!</p>
  <a href="{% url 'login' %}">Click here to login again.</a>
{% endblock %}

Can any tell me what's wrong with it? How to fix this?

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • take a look at LOGOUT_REDIRECT_URL in your settings, here is the documentation https://docs.djangoproject.com/en/2.1/ref/settings/#logout-redirect-url – Shinra tensei Mar 06 '19 at 15:44

1 Answers1

1

If you have defined LOGOUT_REDIRECT_URL in your settings, then LogoutView will redirect to it.

Check to see if you have defined LOGOUT_REDIRECT_URL in your settings, and remove it if you have.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • I added this: STATIC_URL = '/static/' LOGIN_REDIRECT_URL = '/' LOGOUT_REDIRECT_URL = 'LogoutView' –  Mar 06 '19 at 15:49
  • but it show this message: NoReverseMatch at /accounts/logout/ Reverse for 'LogoutView' not found. 'LogoutView' is not a valid view function or pattern name. –  Mar 06 '19 at 15:50
  • That's not what I suggested. If you set `LOGOUT_REDIRECT_URL = 'LogoutView'`, then the `LogoutView` will try to reverse that URL and redirect to it. I asked you to *remove it* from settings, or you can set `LOGOUT_REDIRECT_URL = None`. – Alasdair Mar 06 '19 at 15:51
  • I set : LOGOUT_REDIRECT_URL = None and it redirect administration pages –  Mar 06 '19 at 15:53
  • It not redirects me to my own page –  Mar 06 '19 at 15:54
  • Where is the logout link that you are clicking. Check its URL and make sure it is `http://127.0.0.1:8000/accounts/logout/` and not the Django admin's logout link. If you copy and paste `http://127.0.0.1:8000/accounts/logout/` into your browser bar, then I don't think you'll be redirected if you have `LOGOUT_REDIRECT_URL = None`. – Alasdair Mar 06 '19 at 15:57
  • Setting:LOGOUT_REDIRECT_URL = None –  Mar 06 '19 at 16:03
  • http://127.0.0.1:8000/accounts/logout/ this is the url and it redirect me to adminstraion logout page –  Mar 06 '19 at 16:04
  • I don't have any other suggestions then. Hope you figure out the problem. – Alasdair Mar 06 '19 at 16:05
  • Thanks for your time and care, i am gonna watch tutorial for this –  Mar 06 '19 at 16:06