Reputation: 18318
I have "context_processors.py" in entertainment_website package/app
I configured it settings.py
TEMPLATE_CONTEXT_PROCESSORS = ("django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"entertainment_website.context_processors.load_sidebar_vars")
I would like to somehow debug/print out values from the context_processors.py. What is the best way to do this?
Upvotes: 1
Views: 437
Reputation: 308779
The django debug toolbar is useful for this. Its template panel shows you all the templates rendered, and the values returned by all the context processors.
Upvotes: 1
Reputation: 1874
For debugging in python in general, just add import pdb
to the top of the script which you wish to debug and use pdb.set_trace()
in whichever line you wish to insert a breakpoint.
Run the server and as the control reaches the line containing pdb.set_trace()
take a look at your development server prompt, you can access all local vars to check what vars hold what value.
Upvotes: 0
Reputation: 4320
You can print some value just like this:
def some_context_processor(request):
return {'system_name': 'test'}
and in your html:
{{ system_name }}
Upvotes: 1