Why is my django template context processor not getting called
django, django-templates
Solution
Did you remember to use RequestContext when rendering the template?
As of Django 1.3, there is a new shortcut function, `render`, which uses `RequestContext` by default: :
return render(request, template, {
'tasks': tasks,
})
Problem
I must have missed something in setting up a custom template context as it's never getting called. In settings: ``` TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django_authopenid.context_processors.authopenid", "web.context_processors.my_hat", ) ``` in web/context_processors.py ``` from libs.utils import get_hat, get_project, my_hats print 'heloooo' def my_hat(request): """Insert some additional information into the template context """ import pdb pdb.set_trace() print 'hiiiiiiii' return {'hat': get_hat(request), 'project': get_project(request), } ``` nothing is output and django processes view and displays template without ever hitting this. What have I missed!? Thanks Insin, the bits I had missed: In the view.py ``` return render_to_response(template, { 'tasks': tasks, }, context_instance=RequestContext(request)) ``` In the template: ``` My current hat is {{hat}} ```