Skip to content

Instantly share code, notes, and snippets.

@mihasya
Created July 26, 2009 19:22
Show Gist options
  • Save mihasya/155894 to your computer and use it in GitHub Desktop.
Save mihasya/155894 to your computer and use it in GitHub Desktop.
#make some settings accessible via settings.FOO from within templates
from django.conf import settings
def exposed_settings(request):
context_settings = dict()
for x in settings.TEMPLATE_CONTEXT_SETTINGS:
context_settings[x] = getattr(settings, x)
return { 'settings': context_settings }
TEMPLATE_CONTEXT_PROCESSORS += (
"myapp.context_processors.exposed_settings",
)
TEMPLATE_CONTEXT_SETTINGS = (
'MEDIA_URL',
'ADMIN_MEDIA_PREFIX',
'LANGUAGE_CODE',
#whatever other settings you want to show up in your templates
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment