Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is template context processor in Django 1.5?

Tags:

Is it supposed to be listed in Settings.py automatically or do I have to add it? I am having a ridiculously hard time serving up an image file in development and the docs are too terse for my taste and don't spell things out clearly to me for some reason. I'd like to check to see what my template_context_processors are, but where is it located? It's not in my settings.py file. Do I need to edit this typically?

("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") 
like image 989
user798719 Avatar asked Mar 16 '13 07:03

user798719


1 Answers

In your settings.py you can define TEMPLATE_CONTEXT_PROCESSORS setting.

However, django has defined default values for this setting which is

("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") 

If you want to add your custom template context processor which maintaining the default processors, you can do following in settings.py

import django.conf.global_settings as DEFAULT_SETTINGS  TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + (     'custom_context_processors.my_context_processor', ) 

Refer TEMPLATE_CONTEXT_PROCESSORS doc.

like image 163
Rohan Avatar answered Sep 23 '22 04:09

Rohan