Question

I am trying to get Zinnia running on a django website so I can evaluate it. I have managed to install all its dependencies and everything just fine, and I've created a few posts using the admin tools, but now I am getting errors accessing them!

The error:

KeyError at /weblog/2012/10/12/test-post/

'request'

Request Method:     GET
Request URL:    http://127.0.0.1:8000/weblog/2012/10/12/test-post/
Django Version:     1.4.1
Exception Type:     KeyError
Exception Value:    'request'

Exception Location:     /usr/local/lib/python2.7/site-packages/django/template/context.py in __getitem__, line 54
Python Executable:  /usr/local/bin/python
Python Version:     2.7.3
Python Path:    

['/home/ubuntudev/webtest/twsite',
 '/usr/local/lib/python2.7/site-packages/setuptools-0.6c12dev_r88846-py2.7.egg',
 '/usr/local/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg',
 '/usr/local/lib/python27.zip',
 '/usr/local/lib/python2.7',
 '/usr/local/lib/python2.7/plat-linux2',
 '/usr/local/lib/python2.7/lib-tk',
 '/usr/local/lib/python2.7/lib-old',
 '/usr/local/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/site-packages']

For reference, here is my settings.py and my urls.py. The latter is admittedly a huge mess because I've been screwing around with everything I could think of.

I'm just getting my feet wet with Django, and Zinnia, so please be descriptive in your answers! Thanks in advance.

Was it helpful?

Solution

Django has a system for delivering variables to your template called context processors (here's a good blog post about them). These are useful if you want to have certain pieces of information in every single template. For example, if you didn't want to have to add all the links of a navigation menu to every view/template, you could instead write a template processor to deliver those links as a list to every template.

There are some context processors that are fairly critical to most apps. One such is django.core.context_processors.request which passes the current request objects to every template. This allows you to access a {{ request }} variable in your template, which will give you information about headers etc. that the user has sent (as well as much more).

Anyway, to cut a long story short, you have disabled the above django.core.context_processors.request in your settings:

#TEMPLATE_CONTEXT_PROCESSORS = (
#        "django.contrib.auth.context_processors.auth",
#        'django.core.context_processors.i18n',
#        'django.core.context_processors.request',
#        'django.core.context_processors.media',
#        'django.core.context_processors.static',
#        'zinnia.context_processors.version',
#)

so uncomment all of those and you should be fine

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top