#24265: jinja2 template backend results in KeyError
---------------------------------+-----------------------
Reporter: robhudson | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 1.8alpha1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------
I created a new django 1.8a1 project. I made a couple settings changes,
one of which was changing the single TEMPLATES config's 'BACKEND' to the
jinja2 backend. I have no templates yet or URLs other than the default and
attempted to visit the "It worked!" page but got a 500 instead.
Traceback follows:
{{{
Traceback (most recent call last):
File
"/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py",
line 85, in run
self.result = application(self.environ, self.start_response)
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/contrib/staticfiles/handlers.py", line 64, in __call__
return self.application(environ, start_response)
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/core/handlers/wsgi.py", line 191, in __call__
response = self.get_response(request)
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/core/handlers/base.py", line 217, in get_response
response = self.handle_uncaught_exception(request, resolver,
sys.exc_info())
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/core/handlers/base.py", line 260, in
handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/views/debug.py", line 100, in technical_500_response
html = reporter.get_traceback_html()
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/views/debug.py", line 382, in get_traceback_html
c = Context(self.get_traceback_data(), use_l10n=False)
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/views/debug.py", line 284, in get_traceback_data
default_template_engine = Engine.get_default()
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/utils/lru_cache.py", line 125, in wrapper
result = user_function(*args, **kwds)
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/template/engine.py", line 75, in get_default
django_engines = [engine for engine in engines.all()
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/template/utils.py", line 104, in all
return [self[alias] for alias in self]
File "/Users/rob/.virtualenvs/tastytaps/lib/python2.7/site-
packages/django/template/utils.py", line 93, in __getitem__
backend = params.pop('BACKEND')
KeyError: 'BACKEND'
}}}
I attempted to debug this -- it appears that the template settings are
getting processed twice. The first time it works. The 2nd time it doesn't
since the 'BACKEND' key was popped off the dict. Changing `pop` to `get`
in django/template/utils.py:L93 fixed the issue for me.
--
Ticket URL: <https://code.djangoproject.com/ticket/24265>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.3aaacd07b09bd00a3f798c40ddd65a12%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.