Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.