I'm attempting to follow the Django Tutorial, Part 2, and getting stuck on the last part about templates. The problem I'm experiencing is that I'm changing base_site.html
and no changes are being reflected in my site. I am using Python 3.4
Per the tutorial, I created this file-structure with a "templates" folder in the same directory as manage.py.
- Tutorial
- Tutorial
- polls
- templates
- admin
- base_site.html
- admin
- manage.py
Then, I modified TEMPLATES 'DIRS' to [os.path.join(BASE_DIR,'templates')]
settings.py:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls'
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'Tutorial.urls'
print(os.path.join(BASE_DIR, 'templates'))
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',
],
},
},
]
Then, I modified base_site.html to read:
{% extends "admin/base.html" %}
{% block title %}{{ title }} | {{ site_title|default:_('My Admin Title')
{% endblock %}
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('My Admin Header') }}</a></h1>
{% endblock %}
{% block nav-global %}{% endblock %}
Finally, I navigated to my website at:
http://localhost:8000/admin/
However, I'm still greeted by the title "Site Administration".
I checked the directory it was looking at (the print() line in settings.py), and the directory looks correct:
/home/<user>/Documents/DjangoProjects/Tutorial/templates
I've already checked out this thread and others, but have not found anything helpful. I believe I've followed the tutorial to a tee, can any of you please help me understand how I'm interpreting the tutorial incorrectly? Or is this a documentation bug?