SumNeuron
SumNeuron

Reputation: 5188

Django: flatpages/default.html not found when usign flatepages

I completed Django's 7 part tutorial and am now reading both the official documentation about flat pages as well as this other site.

in

my_project/settings.py

I have added the sites and flatpages apps as well as the SITE_ID.

in

my_project/urls.py

I have added

urlpatterns += [url(r'^pages/', include('django.contrib.flatpages.urls')),]

and because I also need to have flatpages/default.html as a template, in

my_project/templates/flatpages/

there is a file named default.html

to make sure it is found back in

my_projects/settings.py

I updated templates to look like:

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

So I went onto the admin page and added a flatpage named "test" and then went to ...8000:/pages/test/

to get an error message TemplateDoesNotExist.

So where did I go wrong?

Upvotes: 2

Views: 777

Answers (1)

Alasdair
Alasdair

Reputation: 308799

In order for your current DIRS in your TEMPLATES setting to work, make sure that your templates/flatpages/ directory is in your outer my_project directory (the one that contains manage.py), not the inner directory (the one that contains settings.py).

Upvotes: 4

Related Questions