Login

Template context processor to make the settings.py values available in templates

Author:
tamizhgeek
Posted:
May 11, 2011
Language:
Python
Version:
1.3
Tags:
templates context-processor
Score:
2 (after 4 ratings)

The above snippet makes all of the settings.py variables accessible in templates. Add this to the context_processors.py file inside your app directory. After that add the below line to the TEMPLATE_CONTEXT_PROCESSORS in your settings.py.

'*app_name*.context_processors.access_to_settings'
1
2
3
4
from django.conf import settings                                                                                             
                                                                                                                             
def access_to_settings(request):
    return {'SETTINGS' : settings}

More like this

  1. Django 1.2+ template loader for Jinja2 by SimonSapin 4 years, 8 months ago
  2. Use MEDIA_URL in 500 error page by bthomas 6 years, 3 months ago
  3. Output sql_queries in Firebug console when in debug mode by wojas 4 years, 11 months ago
  4. Load static media from secure (SSL) static server (Context Processor) by ianreardon 5 years, 4 months ago
  5. App-specific delegation of template context processors by oogles 1 year, 1 month ago

Comments

Please login first before commenting.