David H
David H

Reputation: 11

Accessing my user defined python global constants in Django template

I am developing an application using Python 2.5 / Google App Engine / Django (for templates)

It seems like a good idea for me to define some global variables (to be used as constants) in my Python code rather than trying to using literals and trying to remember the spelling/capitalisation each time.

There are articles here on how to define and use global variables/constants in my Python code, but is there any way that I can use these global variables in my Django templates apart from passing in a dictionary containing all of them?

Upvotes: 1

Views: 799

Answers (1)

Hamdy Farag
Hamdy Farag

Reputation: 93

You can create your custom context processor, containing all the variables you need be global all over the django application and still call them from any template.

This may help: http://lethain.com/writing-custom-contexts-django/

Upvotes: 5

Related Questions