I upgraded to a fresh install of Django 1.8 and began using Jinja2 as it said that it was supported now and Jinja2 has some features I could use in my project.
After finishing adapting the templates for my app to Jinja2 and taking advantage of the new features now available, I discovered that the contrib app Admin no longer works.
"TemplateDoesNotExist at /admin/login/"
So it turns out that contrib app Admin only has templates made for DjangoTemplates and not for Jinja2. I did the naive thing first and made a symlink in [...]/site-packages/django/contrib/admin
from templates
to jinja2
but the templates were using DjangoTemplates specifics and so Jinja2 would not accept them. I removed the symlink.
The way I have switched over to Jinja2 is by making the following change in my project settings.py
:
TEMPLATES = [
{
- 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'BACKEND': 'django.template.backends.jinja2.Jinja2',
'DIRS': [],
'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',
- ],
- },
},
]
Does anyone know of either:
- How to let the contrib app Admin keep using DjangoTemplates while letting my own app use Jinja2, or
- If there is another admin app as good as the default one which supports Jinja2, or
- If there is something else I have overlooked or should be aware of?
Thank you for your time :)
Copyright Notice:Content Author:「Grim Fandango」,Reproduced 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/29420094/django-1-8-with-jinja2-contrib-app-admin-not-working