What is the standard, preferred way to make settings available to templates in Django 1.8? Currently, I define a custom context processor in my project and then reference it in my TEMPLATES OPTIONS setting. I've looked through the docs but didn't find this issue mentioned. This previous Stackoverflow question says to do what I'm doing but it's over two years old and I'm wondering if there's a newer preferred method. If I've learned one thing from recently upgrading Django, it's to do things the way the framework wants you to do them. You'll have fewer problems this way.
Thanks.
# utils/context_processors.py
from profile.models import UserProxy
from conf.settings import base as base_settings
def global_constants(request):
"""Constants that are available to all templates."""
return {
'site_name': base_settings.SITE_NAME,
'media_url': base_settings.MEDIA_URL
}
# myproject/settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug', # default
'django.template.context_processors.request', # default
'django.contrib.auth.context_processors.auth', # default
'django.contrib.messages.context_processors.messages', # default
'utils.context_processors.global_constants', # project
],
},
},
]