I've installed Django 1.9.7, and I have Pythons 3.4.3 and 2.7.10 on Ubuntu.
These are the steps I've followed:
- Made a new project with django-admin startproject testproject
- cd testproject/testproject
- Made an app within the project with django-admin startapp testapp
- Made a directory for templates in that app with mkdir testapp/templatesand added a very basicindex.htmltemplate in there
- Edited - settings.pyto change the template backend to- django.template.backends.jinja2.Jinja2, by editing line 57 of the default settings file, and to add- testproject.testappto- INSTALLED_APPS; the- TEMPLATESsection is therefore like this:- TEMPLATES = [ { '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', ], }, }, ]
- Edited - urls.py, adding- from testproject.testapp import viewsand a URL pattern- url(r'^$', views.index),
- Edited - testapp/views.pyadding- def index(request): return render(request, 'index.html')
- cd ..
- Ran the server with python3 manage.py runserver, orpython manage.py runserver-- very similar effect
- Take a browser to http://localhost:3000
I get an error. On the command line I get this:
Internal Server Error: /
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/django/template/utils.py", line 86, in __getitem__
    return self._engines[alias]
KeyError: 'jinja2'
Followed by another exception caused "during handling of the above exception", which matches the exception I see in the browser:
Environment:
Request Method: GET
Request URL: http://localhost:3000/
Django Version: 1.9.7
Python Version: 3.4.3
Installed Applications:
['django.contrib.staticfiles', 'testproject.testapp', 'webpack_loader']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/usr/local/lib/python3.4/dist-packages/django/template/utils.py" in __getitem__
  86.             return self._engines[alias]
During handling of the above exception ('jinja2'), another exception occurred:
File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py" in get_response
  174.                     response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py" in get_response
  172.                     response = response.render()
File "/usr/local/lib/python3.4/dist-packages/django/template/response.py" in render
  160.             self.content = self.rendered_content
File "/usr/local/lib/python3.4/dist-packages/django/template/response.py" in rendered_content
  135.         template = self._resolve_template(self.template_name)
File "/usr/local/lib/python3.4/dist-packages/django/template/response.py" in _resolve_template
  90.         new_template = self.resolve_template(template)
File "/usr/local/lib/python3.4/dist-packages/django/template/response.py" in resolve_template
  80.             return select_template(template, using=self.using)
File "/usr/local/lib/python3.4/dist-packages/django/template/loader.py" in select_template
  55.     engines = _engine_list(using)
File "/usr/local/lib/python3.4/dist-packages/django/template/loader.py" in _engine_list
  143.     return engines.all() if using is None else [engines[using]]
File "/usr/local/lib/python3.4/dist-packages/django/template/utils.py" in all
  110.         return [self[alias] for alias in self]
File "/usr/local/lib/python3.4/dist-packages/django/template/utils.py" in <listcomp>
  110.         return [self[alias] for alias in self]
File "/usr/local/lib/python3.4/dist-packages/django/template/utils.py" in __getitem__
  101.             engine = engine_cls(params)
File "/usr/local/lib/python3.4/dist-packages/django/template/backends/jinja2.py" in __init__
  35.         self.env = environment_cls(**options)
Exception Type: TypeError at /
Exception Value: __init__() got an unexpected keyword argument 'context_processors'
I get very similar traces with Python 2.
I found this question which has a similar error message (KeyError: 'jinja2') but seems to be a separate problem, and this bug report which has the same error again whose solution is to install jinja2, but jinja2 is definitely installed. At least, I can run python or python3 and then import jinja2. pip says jinja2 is up to date.
I must be missing something crucial -- any ideas?
 
     
    