Óscar
Óscar

Reputation: 1

django.template.loader can't find template

I'm adding text content to a webapp. When I ran the app in the local server i had no issue, but when i uploaded the template to the server it returns me this error:

    Environment:

Request Method: GET
Request URL: http://www.centros-sbc.com/domiciliaciones

Django Version: 1.5.1
Python Version: 2.7.3
Installed Applications:
    ('django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'suit',
    'django.contrib.admin',
    'sbcweb',
    'south',
    'compressor',
    'django.contrib.sitemaps',
    'captcha')
Installed Middleware:
    ('django.middleware.cache.UpdateCacheMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware')

Template Loader Error:
Django tried loading these templates, in this order:
**Using loader django.template.loaders.filesystem.Loader: **
**/home/manager/webs/sbc-web/sbcweb/templates/general/domiciliaciones.html (File exists)**

Using loader django.template.loaders.app_directories.Loader:
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/general/domiciliaciones.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/suit/templates/general/domiciliaciones.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/general/domiciliaciones.html (File does not exist)
**/home/manager/webs/sbc-web/sbcweb/templates/general/domiciliaciones.html (File exists)**
/usr/local/lib/python2.7/dist-packages/compressor/templates/general/domiciliaciones.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/sitemaps/templates/general/domiciliaciones.html (File does not exist)



Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/manager/webs/sbc-web/sbcweb/views/general.py" in domiciliaciones
27.     return render_to_response('general/domiciliaciones.html', response, context_instance=RequestContext(request))
File "/usr/local/lib/python2.7/dist-packages/django/shortcuts/__init__.py" in render_to_response
29.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string
170.         t = get_template(template_name)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in get_template
146.     template, origin = find_template(template_name)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in find_template
139.     raise TemplateDoesNotExist(name)

Exception Type: TemplateDoesNotExist at /domiciliaciones
Exception Value: general/domiciliaciones.html

here are my template loaders:

TEMPLATE_LOADERS = (
    #'django_mobile.loader.Loader',
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    #'django.template.loaders.eggs.Loader',
)

My template dirs:

TEMPLATE_DIRS = (
    os.path.join(APP_PATH, "templates"),
)

the app path:

APP_PATH = os.path.dirname(os.path.abspath(__file__))

Here's the thing. I just did few modifications on the text of /domiciliaciones.html processed the .po translation files and overwritted the translation files and the .html

I tried to fix the page returning to the original (without my changes) but it doesn't work neither. If someone could help it would be great, I'm kind of desperate to fix that. I don't know if you need more information about the app, just let me know!

Many thanks in advance!

Upvotes: 0

Views: 1771

Answers (1)

MWY
MWY

Reputation: 1181

Maybe I can answer your question! In Django 1.8.2, Deprecated since version 1.8: Set the DIRS option of a DjangoTemplates backend instead.,so,you should not set TEMPLATE_DIRS,In my opintion,you should set

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['templates'],
        'APP_DIRS': True,
       }
]   

I spent a half of day to solve this problem in my WebApp! I guess this will help you!

Upvotes: 2

Related Questions