简体   繁体   中英

Path to template directory not working in settings.py

Currently created a templates folder inside my project folder.

Then I added the admin folder and the file base_site.html to be able to change the Django admin title:

Home / Django / mysite / templates / admin / base_site.html

However, it doesn't change. My settings.py file below:

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',
            ],
        },
    },
]

Of Avinash Raj's request:

urls.py:

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
]

views.py:

from django.shortcuts import render

Since Django 1.7 you do not need to rewrite any templates to change admin title or header but just set site_header , site_title , and index_title in admin.py & then hook them in urls.py . Look here: https://stackoverflow.com/a/24983231/5253807

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM