2

Here is my TEMPLATES section in settings.py:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

I'm using template inside application directory and it works. But whenever I'm trying to extend it with layout from global templates directory (os.path.join(BASE_DIR, 'templates'), which exists, I tested), django raises TemplateDoesNotExist error. Here is Template-loader postmortem, which does not includes my DIRS directory:

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/layouts/default.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/layouts/default.html (File does not exist)
/home/foundation/public/foundation/foundation/event_request/templates/layouts/default.html (File does not exist)

**UPDATE: ** seems like apache loads django 1.5 instead of django 1.8. This might be a problem.

Mee
  • 458
  • 1
  • 6
  • 21

2 Answers2

2

After log entry

Using loader django.template.loaders.filesystem.Loader:

loader should print all possible locations that it tried to find your template, like it was after similar log from app_directories loader. If there is no paths here, double check if your TEMPLATES setting is defined correctly, is not overwritten somewhere later in your settings or other files and if Django is loading that settings file correctly.

You can throw some exception to get 500 server error when DEBUG is set to True, on error page you will get handy list of all settings that Django sees.

Also check if your WSGI server is loading proper version of django, older versions doesn't have TEMPLATE setting (it was splitted between multiple settings).

GwynBleidD
  • 20,081
  • 5
  • 46
  • 77
  • According to your update, in django 1.5 there is no `TEMPLATES` setting. Specify some virtualenv for your WSGI in Apache, that will solve the problem. – GwynBleidD Sep 30 '15 at 09:15
0

Problem has to do with wrong virtualenv and actual use of Django 1.5.1 instead of 1.8. I'll save this post, maybe it will help someone with similar problem in future.

Mee
  • 458
  • 1
  • 6
  • 21