As of the documentation, there should be variables called "debug" and "sql_queries" usable in templates if all requirements are met.
I have set the following (and checked their values with the debug toolbar):
DEBUG = TrueTEMPLATE_DEBUG = TrueTEMPLATE_CONTEXT_PROCESSORS left at its default value (containing 'django.core.context_processors.debug')INTERNAL_IPS = ('127.0.0.1',) (and the debug toolbar shows REMOTE_ADDR = '127.0.0.1' under "HTTP Headers")TEMPLATE_STRING_IF_INVALID = "(invalid variable '%s'!)"When rendering a template containing {{ sql_queries }} {{ debug }}, I get (invalid variable 'sql_queries'!) (invalid variable 'debug'!) as output.
My Django version is 1.2.3. What am I missing here?
In your view, are you creating a Context, or a RequestContext? It needs to be RequestContext.
Ned Batchelder's answer led me to the right direction. A RequestContext instance must be explicitly passed when using render_to_response:
return render_to_response("some.template.file",
templateArguments,
context_instance = RequestContext(request))
From Django 1.3, you can use the render function as shorthand:
return render(request, "some.template.file", templateArguments)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With