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.

6
  • How are you defining BASE_DIR? Commented Sep 30, 2015 at 9:01
  • BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file))) Commented Sep 30, 2015 at 9:03
  • Does it need to be a complete directory path and not a path fragment? Commented Sep 30, 2015 at 9:05
  • It is complete path. Here what TEMPLATE structure looks like runtime: TEMPLATES [{'APP_DIRS': True, 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['/home/foundation/public/foundation/templates'], [...] Commented Sep 30, 2015 at 9:06
  • 1
    What's more interesting for me is the fact that directory is not listed in Template-loader postmortem. Commented Sep 30, 2015 at 9:08

2 Answers 2

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).

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.