Saturday, March 28, 2015

Jinja2 with Django 1.8c1 & cannot import name 'Environment'

Does anybody see what I may be doing wrong here?

I followed this example:
https://github.com/aaugustin/mtefd/blob/master/multiple-template-engines.rst#jinja2-backend


The project is at:
/www/pbs_site

/www/pbs_site$ python manage.py check
System check identified no issues (0 silenced).

##### Error #####

ImportError at /

cannot import name 'Environment'

Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.8c1
Exception Type: ImportError
Exception Value:

cannot import name 'Environment'

Exception Location: /www/pbs_site/jinja2.py in <module>, line 4
Python Executable: /www/pbs-venv/bin/python
Python Version: 3.4.3
Python Path:

['/www/pbs_site',
'/www/pbs_site/pbs_site',
'/www/pbs-venv/bin',
'/usr/local/lib/python34.zip',
'/www/Python-3.4.3/Lib',
'/www/Python-3.4.3/Lib/plat-linux',
'/www/Python-3.4.3/build/lib.linux-i686-3.4',
'/www/pbs-venv/lib/python3.4/site-packages']

Server time: Fri, 27 Mar 2015 11:19:56 -0500

##### Code #####

/www/pbs_site$ grep ^TEMPLATES -A 23 pbs_site/settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'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',
],
},
},
{
'BACKEND': 'django.template.backends.jinja2.Jinja2',
'NAME': 'jinja2',
'DIRS': [],
'APP_DIRS': False,
'OPTIONS': {
'environment': 'jinja2.Environment',
},
},
]

/www/pbs_site$ cat jinja2.py
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.urlresolvers import reverse

from jinja2 import Environment


def environment(**options):
env = Environment(**options)
env.globals.update({
'static': staticfiles_storage.url,
'url': reverse,
})
return env

--
Rolf

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5517245B.1090006%40personalized-books.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment