[Answered ]-Question in one of Cory Schafer's tutorials for Django

1👍

Django has some build-in context processors which are applied on top of context data and are universally available in every template. django.contrib.messages.context_processors.messages is one such.

enter image description here

Thus the messages are universally accessible to every template. You can read more here https://docs.djangoproject.com/en/3.2/ref/templates/api/#django.template.Context . Furthermore you can find the list of all the context processors in your settings.py file inside the Templates options –


TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        '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',
            ],
        },
    },
]

Here you can see the messages context processor.

Leave a comment