---------- Forwarded message ---------
From: Sudipta Sen <
sanbo...@gmail.com>
Date: Tue Nov 04 2014 at 6:46:17 PM
Subject: Global Variable
To: <
django...@googlegroups.com>
Hi folks,
I am very new to django and facing some problems.
1. I need a global variable, which I can use throughout the application. Like let's say base_url.
- I tried defining one variable in settings and using it places like this
- from django.conf import settings
- url = settings.BASE_URL+'login'
- This gives me an error : non-keyword arg after keyword arg
- Also this process seems to be painful, every time I have to import settings in each of my views.
2. I need a custome context variable to be passed everytime.
- I tried this: in the same directory where my settings is, I created a context_processors.py
- context_processors.py:
- def baseurl(request):
- return {"base_url" : "/some/url/"}
- In my settings.py file I am adding this line :
TEMPLATE_CONTEXT_PROCESSORS += ('context_processors.baseurl',)
This gives me an error : NameError: name 'TEMPLATE_CONTEXT_PROCESSORS' is not defined
Please help me on these issues.