Context processors
System for making data globally available to all templates without manual passing.
Workflow: Creating a custom context processor
Create
apps/my_app/context_processors.py:def site_info(request): return { 'site_name': 'My Awesome Project', 'support_email': 'support@example.com', }
Add the dotted path of your function to the
context_processorslist insettings.py:TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'apps.my_app.context_processors.site_info', ], }, }, ]