BAE
BAE

Reputation: 8946

Django: why django.contrib.auth.views.logout not use registration/logged_out.html

Django 1.10, My Urls:

from django.conf.urls import url
from django.contrib.auth.views import login, logout

urlpatterns = [
    url(r'^login/$', login, name='login'),
    url(r'^logout/$', logout, name='logout'),
]

My account/templates/registration/logged_out.html:

{% extends "base.html" %}

{% block title %}Logged out{% endblock %}

{% block content %}
    <h1>Logged out</h1>
    <p>You have been successfully logged out. You can <a href="{% url "login" %}">log-in again</a>.</p>
{% endblock %}

Instead of registration/logged_out.html used, the admin logout html used (see the following). enter image description here

Why? How to debug? Thanks

UPDATE

part of settings.py

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates'),],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

Part of templates/base.html (Here templates/ fold is at the same fold with account fold, at the project directory.):

    {% if request.user.is_authenticated %}
        Hello {{ request.user.username }},
        <a href="{% url 'logout' %}">Logout</a>
    {% else %}
        <a href="{% url 'login' %}">Log-in</a>
    {% endif %}

Upvotes: 0

Views: 377

Answers (1)

Alasdair
Alasdair

Reputation: 309089

The app directories template loader searches through your app's template directories in the order of INSTALLED_APPS.

You need to move your app account above django.contrib.admin in your INSTALLED_APPS setting, so that Django finds your custom template before the one from the admin app.

Upvotes: 1

Related Questions