Django flat pages not working

I am reading and following the book "Django Practical Projects: Second Edition", and many books are already outdated to the point where the whole chapter will not work at all. Now I am trying to create my first flat page and I am getting 404 error.

I am trying to use the built-in django.contrib.flatpages application, and I have already created my first flat page through the admin panel:

enter image description here

Here is my urls.py file:

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',


    url(r'^admin/', include(admin.site.urls)),
    (r'', include('django.contrib.flatpages.urls')) #ADDED THIS LINE FOR FLATPAGES
)

Here is what I did with my settings.py file:

SITE_ID = 1 # REQUIRED FOR 'django.contrib.flatpages'


INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.flatpages', # ADDED FOR FLATPAGES
    'south',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', #FOR FLATPAGES
)

So, what about everything that I have done so far, and I expect "TemplateDoesNoesExist on / first page /" when the navigation, as in the book, says: http://example.com:1006/first-page/

But instead, I just get 404 error.

Django flatpages?

+3
2

, , , . Apress. , 3 .

enter image description here

, : , SITE_ID settings.py URL- " " . , "4" - . settings.py :

SITE_ID = 4

, " 1", . , .

+5

Page 18, : " Django". , , TEMPLATE_DIRS . (. 18-21)

-1

All Articles