Home:ALL Converter>Django TemplateDoesNotExist in production server when it works in development

Django TemplateDoesNotExist in production server when it works in development

Ask Time:2017-04-01T04:00:27         Author:Marijus

Json Formatter

I get the following error. It's ONLY IN PRODUCTION where I deploy Django application using apache + mod_wsgi. IT WORKS PERFECTLY IN DEVELOPMENT server(my computer):

TemplateDoesNotExist at /
base.html

postmortem. as you can see only one of my two folders from settings are being searched:

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
/home/bot_frontend/horses/templates/base.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/base.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/base.html (File does not exist)
/home/virtualenvs/bot_frontend/lib/python2.7/site-packages/django_extensions/templates/base.html (File does not exist)

Here are my settings. The base.html template is in "templates" folder.:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, "templates"),
            os.path.join(BASE_DIR, "horses/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',
            ],
        },
    },
]

Here I confirm that this template actually exists:

>>> from django.template.loader import get_template
>>> get_template("base.html")
<django.template.backends.django.Template object at 0x7f6af68d38d0>

As you can see only one folder out of two in my template dirs are being searched while in development server it works just fine. Any ideas why this could be ? Is it possible it's some kind of permissions issue.

Author:Marijus,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43148780/django-templatedoesnotexist-in-production-server-when-it-works-in-development
yy