Login

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

Author:
tamizhgeek
Posted:
May 11, 2011
Language:
Python
Version:
1.3
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. codigo alto nivel by MrRocklion 4 weeks ago
  2. Load template from specific app by Krzysiek555 1 month, 2 weeks ago
  3. PostgreSQL JSON subqueries by dolamroth 1 month, 3 weeks ago
  4. "Magic Link" Management Command by webology 6 months, 3 weeks ago
  5. Closest ORM models to a latitude/longitude point by simonw 6 months, 3 weeks ago

Comments

Please login first before commenting.