Я получаю странную ошибку TemplateDoesNotExist в моем Django-проекте. Фактически загрузчик находит файл шаблона (который также существует, и я хочу позвонить!). Вот вывод:TemplateDoesNotExist, но файл найден
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
[...]/anaconda3/lib/python3.4/site-packages/django/contrib/admin/templates/osm/index.html (File does not exist)
[...]/anaconda3/lib/python3.4/site-packages/django/contrib/auth/templates/osm/index.html (File does not exist)
[...]/projekt/osm/templates/osm/index.html (File exists)
[...]/projekt/flotte/templates/osm/index.html (File does not exist)
Почему ошибка возникает, даже если файл найден?
EDIT: после некоторого тестирования, кажется, как все HTML-шаблоны, которые расширяют мой base.html
не работают в то время как автономные HTML-шаблоны работы:
{% extends 'base.html' %}
{% load static %}
{% block main_content %}
[...]
Мой base.html
находится в [...]/projekt/static/templates
. Этот путь определяется в TEMPLATE_DIRS. Довольно уверен, что это сработало до обновления до django 1.8.2! :(
Как сделать проект-шаблон-Path [...]/projekt/static/templates
мои настройки: [полный см http://pastebin.com/rn2hSj5Y]
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
#Template location
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, "static", "templates"),
#os.path.join(PROJECT_PATH, "osm", "templates", "osm"),
#os.path.join(PROJECT_PATH, "flotte", "templates", "flotte"),
)
мой соответствующий вид:
def index(request):
# Request the context of the request.
# The context contains information such as the client's machine details, for example.
context = RequestContext(request)
context_dict = {'boldmessage': "I am bold font from the context"}
return render_to_response('osm/index.html', context_dict, context)
Вы проверили разрешения на файл? –
Да, '[...]/projekt/osm/templates/osm/index.html' читается: '-rwxrwxr-- 1 пользователь plugdev 982 5 октября 2014 index.html *' – Klaster
Я предполагаю, что вы не используя Django 1.8 - в какой версии вы работаете? 1.8 изменяет настройки шаблона. – FlipperPA