Django context processors
They are useful if you want particular kind of into to make available in ALL templates. Like github repo update time/date in Rights app
Create context_processors.py
, place it anywhere in the project. Add a simple
function in it:
from datetime import datetime def current_time(request): return {'current_time': datetime.now()}
If you have placed the .py
file in the root root dir, then in TEMPLATES =
array add this:
'context_processors.current_time',
Now try to reach it from any template:
The current date and time is: {{ current_time }}