How to fix VariableDoesNotExist exception in Django

When Django greets you with this exception:

TemplateSyntaxError at /

Caught VariableDoesNotExist while rendering: Failed lookup for key [request] in...

you are probably using a template tag that requires the request context processor. Simply add ‘django.core.context_processors.request’ to the TEMPLATE_CONTEXT_PROCESSORS tuple in your settings file.

10 thoughts on “How to fix VariableDoesNotExist exception in Django

  1. Sorry if it didn’t help you. I was facing this problem and adding the context processor was the solution. I appreciate any feedback how to make this post more useful.

  2. I for one found this tip a lifesaver. The error messages didn’t help and this suggestion solved the issue perfectly.

    Posts like yours are why I love the internet 🙂

  3. Pingback: Creating base.html and improving the navigation bar. | Anthony Honstain SDE

  4. I’m having this now. And the context processor is already there, but django still complains…