You want a context processor. Every time you render a template, you give it a “context”; this is a dictionary-like object whose keys are variable names and whose values are the values of the variables.
For example..
Create a file my app/context_processors
def get_balance(request):
do something
return {'balance': 0}
add it to your settings:
TEMPLATE_CONTEXT_PROCESSORS = ('myapp.context_processors.get_balance',)
done.