Skip to content
Advertisement

how to insert some text in all django context using django middleware

this my middleware code :

JavaScript

this is the settings.py:

JavaScript

and the view is :

JavaScript

the html is :

JavaScript

but it not show {{ss}}:

JavaScript

so how do i show :

JavaScript

how to insert some text in all django context using django middleware,

so that i cant use to insert the text everytime ,

thanks

Advertisement

Answer

To meet your initial goal, I do not think the BeforeFilter middle ware is required. What we need is just a template context processor.

Write a context processor as following:

JavaScript

then add the context processor to TEMPLATE_CONTEXT_PROCESSORS list

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement