creating my own context processor in django
Posted
by dotty
on Stack Overflow
See other posts from Stack Overflow
or by dotty
Published on 2010-05-23T22:19:00Z
Indexed on
2010/05/23
22:20 UTC
Read the original article
Hit count: 365
Hay, I have come to a point where i need to pass certain variables to all my views (mostly custom authentication type variables).
I was told writing my own context processor was the best way to do this, but i am having some issues.
My settings file looks like this
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.contrib.messages.context_processors.messages",
"sandbox.context_processors.say_hello",
)
As you can see i have a module called 'context_processors' and a function within that called 'say_hello'.
This looks like
def say_hello(request):
return {
'say_hello':"Hello",
}
Am i right to assume i can now do this within my views
{{ say_hello }}
because it doesn't return anything.
© Stack Overflow or respective owner