Hi Rolf,

Since your `jinja2.py` file sits before your installed `jinja2` package 
directory in your PYTHONPATH you end up trying to import `Environement` 
from your the module you're defining and not the installed `jinja2` module.

Rename your jinja2.py file something else and things should be working.

Simon

Le samedi 28 mars 2015 18:00:47 UTC-4, Rolf Brudeseth a écrit :
>
> 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
>  
> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Faaugustin%2Fmtefd%2Fblob%2Fmaster%2Fmultiple-template-engines.rst%23jinja2-backend&sa=D&sntz=1&usg=AFQjCNFAhfrsQ35YRZXMrNA4YLXod94k5A>
>  
>
>
> 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 [email protected].
To post to this group, send email to [email protected].
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/e43826c4-39b5-4336-84ad-381d4c06d8c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to