I am following this thread here... How to use jinja2 as a templating engine in Django 1.8
I can't seem to find any solid docs on switching to jinja2 templates and how to setup django for it. All the docs seem to have some gaps, or I am missing somehting really obvious. Anyway, I set everything up just like the thread above, except when I try to go somewhere where the template would be loaded I get...
TemplateDoesNotExist
Django tried loading these templates, in this order:
...
But it does not list any of my jinja/ template directories that I specified. Why would this be?
EDIT ADDING TRACE AND SETTINGS:
TEMPLATES = (
{
'BACKEND': 'askbot.skins.template_backends.AskbotSkinTemplates',
},
{
'BACKEND': 'django.template.backends.jinja2.Jinja2',
'DIRS': [os.path.join(PROJECT_ROOT, 'templates/jinja2')],
'APP_DIRS': True,
'OPTIONS': {'environment': 'myproject.jinja-import.Environment',},
},
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(PROJECT_ROOT, 'templates',),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.core.context_processors.request',
'django.contrib.auth.context_processors.auth',
]
}
},
)
Traceback:
File "/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/Django-1.8.8-py2.7.egg/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/jeff/Django/langalang-askbot/langalang/main/views.py" in page
71. context_instance=RequestContext(request, context))
File "/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/Django-1.8.8-py2.7.egg/django/shortcuts.py" in render
89. using=using)
File "/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/Django-1.8.8-py2.7.egg/django/template/loader.py" in render_to_string
137. raise TemplateDoesNotExist(template_name)
Exception Type: TemplateDoesNotExist at /ko/
Exception Value: main/page.html
Template Loader Error:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/home/jeff/Django/langalang-askbot/langalang/templates/main/page.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/Django-1.8.8-py2.7.egg/django/contrib/auth/templates/main/page.html (File does not exist)
/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/Django-1.8.8-py2.7.egg/django/contrib/admin/templates/main/page.html (File does not exist)
/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/Django-1.8.8-py2.7.egg/django/contrib/sitemaps/templates/main/page.html (File does not exist)
/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/django_compressor-1.5-py2.7.egg/compressor/templates/main/page.html (File does not exist)
/home/jeff/Django/langalang-askbot/langalang/askbot-dev/askbot/templates/main/page.html (File does not exist)
/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/django_robots-1.1-py2.7.egg/robots/templates/main/page.html (File does not exist)
/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/django_celery-3.1.17-py2.7.egg/djcelery/templates/main/page.html (File does not exist)
/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/django_tinymce-1.5.3-py2.7.egg/tinymce/templates/main/page.html (File does not exist)
/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/django_recaptcha-1.0.5-py2.7.egg/captcha/templates/main/page.html (File does not exist)
/home/jeff/Django/langalang-askbot/venv/local/lib/python2.7/site-packages/django_avatar-2.2.1-py2.7.egg/avatar/templates/main/page.html (File does not exist)
view that is loading the template:
def page(request, page_title='home'):
context = {
'page_title': page_title
}
if page_title == 'home':
#This query pulls the language instructions objects and then orders it alphabetically by the 'full_title' field
language_pairs = LangPairInstruction.objects.filter(active=True).order_by('full_title')
context['language_pairs'] = language_pairs
elif page_title == 'contact':
form_class = ContactForm(initial={'subject': _('Subject'), 'name': _('Name'), 'email': _('Email'), 'content': _('Content')})
context['ContactForm'] = form_class
elif page_title == 'about':
pass
else:
raise Http404
return render(
request,
'main/page.html',
context_instance=RequestContext(request, context))