Ticket #3818: context_settings.diff

File context_settings.diff, 1.1 KB (added by m@…, 15 years ago)

context processor for exposing settings in templates.

  • django/conf/global_settings.py

     
    168168#    'django.core.context_processors.request',
    169169)
    170170
     171TEMPLATE_CONTEXT_SETTINGS = (
     172    'MEDIA_URL',
     173    'ADMIN_MEDIA_PREFIX',
     174    'LANGUAGE_CODE',
     175)
     176
    171177# Output to use in template system for invalid (e.g. misspelled) variables.
    172178TEMPLATE_STRING_IF_INVALID = ''
    173179
  • django/core/context_processors.py

     
    5757def request(request):
    5858    return {'request': request}
    5959
     60def exposed_settings(request):
     61    context_settings = dict()
     62    for x in settings.TEMPLATE_CONTEXT_SETTINGS:
     63        context_settings[x] = getattr(settings, x)
     64    return {'settings': context_settings}
     65
    6066# PermWrapper and PermLookupDict proxy the permissions system into objects that
    6167# the template system can understand.
    6268
Back to Top