In the chapter under the heading “Add links to nav to login and logout”, users are told to update base.html that has the load staticfiles up top.
{% load staticfiles %}
<!doctype html>
<html>
<head>
<title>
{% block title %}
My Hello Web App Project
{% endblock %}
</title>
<link rel="stylesheet" href="{% static 'css/style.css' %}" />
{% block header %}{% endblock %}
</head>
<body>
<header>
<h1>Hello Web App</h1>
<nav>
<ul>
<li><a href="{% url 'home' %}">Home</a></li>
<li><a href="{% url 'about' %}">About</a></li>
<li><a href="{% url 'contact' %}">Contact</a></li>
{% if user.is_authenticated %}
<li><a href="{% url 'auth_logout' %}">Logout</a></li>
{% else %}
<li><a href="{% url 'auth_login' %}">Login</a></li>
<li><a href="{% url 'registration_register' %}">Register</a></li>
{% endif %}
</ul>
</nav>
</header>
{% block content %}{% endblock %}
{% block footer %} {% endblock %}
</body>
</html>
That’s what mine looks like. Is that what you’re referring too?
Just for measure though, I’m going to share all the relevant files related to this chapter that were updated.
Settings.py
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 's(0d2_(y(@dru2556=x&mx7p#33c(=ry+@ak9g@l-+jue6f#rs'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'collection',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles'
'registration',
]
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'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 = 'hellowebapp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
},
},
]
WSGI_APPLICATION = 'hellowebapp.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/'
ACCOUNT_ACTIVATION_DAYS = 7
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
DEFAULT_FROM_EMAIL = '[email protected]'
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
EMAIL_PORT = 1025
LOGIN_REDIRECT_URL = "home"
URLS.py
from django.conf.urls import url, patterns, include
from django.contrib import admin
from collection import views
from django.views.generic import TemplateView
urlpatterns = [
url(r'^$',views.index, name='home'),
url(r'^about/$', TemplateView.as_view(template_name='about.html'), name = 'about'),
url(r'^contact/$', TemplateView.as_view(template_name='contact.html'), name = 'contact'),
url(r'^things/(?P<slug>[-\w]+)/$', views.thing_detail, name = 'thing_detail'),
url(r'^things/(?P<slug>[-\w]+)/edit/$', views.edit_thing, name = 'edit_thing'),
url(r'^accounts/', include('registration.backends.simple.urls')),
url(r'^admin/', include(admin.site.urls)),
]
And then there is the login, logout, registration complete, and registration form html pages that were created. If those are needed say the word and I shall share them.
Maybe you could see something in all that code that points to the problem?