I'm following the tutorial for django 1.7 (again). I cannot get the admin site to update. I've followed this:
Django: Overrideing base_site.html
this:
Custom base_site.html not working in Django
and a couple of offsite things links.
My settings file looks like this:
""" Django settings for website project.
For more information on this file, see https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see https://docs.djangoproject.com/en/1.7/ref/settings/ """
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = ''
# SECURITY WARNING: don't run with debug turned on in production! DEBUG = True
TEMPLATE_DEBUG = True
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles', 'blog',
)
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', )
ROOT_URLCONF = 'website.urls'
WSGI_APPLICATION = 'website.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '', 'USER': 'root', 'PASSWORD': '', 'HOST': '127.0.0.1', 'PORT': '3306',
} }
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'GMT'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
And I know my file structure is working because if I cut everything out of the base_site.html and replace it with 'wtf' that's exactly what displays when I visit the admin site. I've gone as far as to delete the admin/base_site.html from the django install but still I get the 'Django administration'.
When it doesn't say 'wtf' my base_site.html looks like this:
{% extends "admin/base.html" %}
{% block title %}{{ title }} | {{ site_title|default:_('whatever site admin') }}{% endblock %}
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('whatever site administration') }}</a></h1>
{% endblock %}
{% block nav-global %}{% endblock %}
I guess this must be something to do with 1.7 as I got it working in 1.6 but I've checked the docs for 1.6, 1.7 and dev and can't find what's wrong.
I'm developing on windows in a virtual env running a local MySQL db.
To start off, I am not sure if it was a copy/paste issue or if you actually have TEMPLATE_DIRS commented out. It will need to be a non-commented line:
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
As for the real problem, you have to replace more of your template to make it work because site_title is defined here: https://github.com/django/django/blob/1.7/django/contrib/admin/sites.py#L36 and site_header is defined here: https://github.com/django/django/blob/1.7/django/contrib/admin/sites.py#L39
Default will only work if these do not exist, so your template should look like this:
{% extends "admin/base.html" %}
{% block title %}{{ title }} | whatever site admin{% endblock %}
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">whatever site administration</a></h1>
{% endblock %}
{% block nav-global %}{% endblock %}
You can learn more about the default tag here: https://docs.djangoproject.com/en/1.7/ref/templates/builtins/#default
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With