56π
β
When you specify this:
TEMPLATE_CONTEXT_PROCESSORS = ('myapp.processor.foos',)
In your settings file, you are overriding the Djangoβs default context processors. In order to extend the list, you need to include the default ones in your settings:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"myapp.processor.foos",
)
Note, the settings above are the defaults (plus your processor) for django 1.1.
π€TM.
177π
You need to add the default values of TEMPLATE_CONTEXT_PROCESSORS. However, instead of hard-coding those values, which will be tied to a specific version of Django, you can append your context processor to the default values by the following:
from django.conf import global_settings
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
"myapp.processor.foos",
)
Make sure to include the trailing comma in the tuple, so that Python recognizes it as a tuple.
π€Greg Glockner
- [Django]-Embed YouTube video β Refused to display in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'
- [Django]-How to check the TEMPLATE_DEBUG flag in a django template?
- [Django]-Change a form value before validation in Django form
7π
Here what worked for me for Django 1.3
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.contrib.messages.context_processors.messages",
"myapp.processor.foos", )
π€David Dehghan
- [Django]-How to write setup.py to include a Git repository as a dependency
- [Django]-Django-taggit β how do I display the tags related to each record
- [Django]-Programmatically saving image to Django ImageField
Source:stackexchange.com