What we could do is to add all this information to the response dictionary. However, it would contradict the DRY principle of Django.
A good approach is to use a customized Context Processor, which will add to the dictionary the returned variables of the function.
Specifically, the modifications we must do can be the following:
- Define the Context Processor function, like for example:
return {'additional_values': ['a','b','c']}
- Load the function inside the TEMPLATE_CONTEXT_PROCESSORS variable of the setting.py:
...
"path_to_context_processor_function.context_processor_function",)
- Use the variables inside the templates like any other variables of the dictionary
http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/
https://docs.djangoproject.com/en/1.1/ref/settings/#std:setting-TEMPLATE_CONTEXT_PROCESSORS
http://stackoverflow.com/questions/335231/in-django-is-it-possible-to-access-the-current-user-session-from-within-a-custo