Django 1.8 with Jinja2: Contrib app Admin not working
NickName:Grim Fandango Ask DateTime:2015-04-03T02:37:25

Django 1.8 with Jinja2: Contrib app Admin not working

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:

  1. How to let the contrib app Admin keep using DjangoTemplates while letting my own app use Jinja2, or
  2. If there is another admin app as good as the default one which supports Jinja2, or
  3. 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

Answers
Alasdair 2015-04-02T19:28:12

The admin app does not come with Jinja2 templates. You need to configure your project to use Django and Jinja2 templates.\n\nThe Django template docs has the following example.\n\nTEMPLATES = [\n {\n 'BACKEND': 'django.template.backends.django.DjangoTemplates',\n 'DIRS': [\n '/home/html/example.com',\n '/home/html/default',\n ],\n },\n {\n 'BACKEND': 'django.template.backends.jinja2.Jinja2',\n 'DIRS': [\n '/home/html/jinja2',\n ],\n },\n]\n",


More about “Django 1.8 with Jinja2: Contrib app Admin not working” related questions

Django 1.8 with Jinja2: Contrib app Admin not working

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 templat...

Show Detail

Django 1.8 not using Jinja2 template engine

I have followed the instructions on using jinja2 with django1.8. ---> #settings.py TEMPLATES = [ { 'BACKEND': 'django.template.backends.jinja2.Jinja2', 'DIRS': [

Show Detail

duplicate a proxy model in admin on django 1.8

I want to have a model that appear two times on django-admin, on two differents apps, because admins have access to differents apps. On stackoverflow, it is said this should work, but the answers ...

Show Detail

Django 1.8 HstoreField admin interface

New Django 1.8 provides HstoreField. I have extended user model with HstoreField data **#models.py** from django.contrib.postgres.fields import HStoreField from django.contrib.auth.models import

Show Detail

How to use jinja2 as a templating engine in Django 1.8

I have been looking on how to use jinja2 in django 1.8, but there is no complete source for using django with jinja2. I was wondering if you guys knew the process for using jinja2 in django. I have

Show Detail

Django jinja2 template, extends another template. Django renders base template without jinja2

I'm using jinja2 to render a template in django: TEMPLATES = [ { "BACKEND": "django.template.backends.jinja2.Jinja2", "DIRS": [os.path.join(BASE_DIR, "templates/jinja2/"

Show Detail

Context Processors are not working with Jinja2 in Django

Context Processors are not working with Jinja2(Ver 2.10) in Django(Ver 2.0.5). This is what i have done. Created a context processor as follows: def test_con_proc(request): return { 'test_con_...

Show Detail

Jinja2 templating not working in in Django 1.9

Per the instructions on the Django 1.9 tutorial I've added another file in the project root with the Environment settings - from __future__ import absolute_import # Python 2 only from django.con...

Show Detail

DoesNotExist at /admin/login/ after upgrading to Django 1.8

After upgrade from django 1.7 to 1.8, I can't able to access my admin portal. I get the following error: DoesNotExist at /admin/login/ Site matching query does not exist. As mentioned in other

Show Detail

PEP8 checker testcase in Django 1.8 project

I'm trying to add pep8 checker testcase to my Django 1.8 project. I found this package: https://github.com/TracyWebTech/django-test-pep8 If I followed the README.md install guide except the

Show Detail