djangoflash.context_processors — Django-Flash context processors

This module provides the context processor that exposes djangoflash.models.FlashScope objects to view templates.

To plug this context processor to your Django project, edit your project’s settings.py file as follows:

TEMPLATE_CONTEXT_PROCESSORS = (
    'djangoflash.context_processors.flash',
)

Doing this, the view templates will be able to access the flash contents using the flash context variable.

Warning

Your views should use the RequestContext class to render the templates, otherwise the flash variable (along with all other variables provided by other context processors) won’t be available to them. Please read the Django docs for further instructions.

djangoflash.context_processors.flash(request)

This context processor gets the FlashScope object from the current request and adds it to the template context:

<html>
    <head></head>
    <body>
        request.flash['message'] = {{ flash.message }}
    </body>
</html>

Previous topic

djangoflash.middleware — Django-Flash middleware

Next topic

djangoflash.decorators — Django-Flash decorators

This Page