---------- Forwarded message ---------
From: Sudipta Sen <[email protected]>
Date: Tue Nov 04 2014 at 6:46:17 PM
Subject: Global Variable
To: <[email protected]>
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.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAO0Um5FCybTFF9BeJn%3DTw755EFsCVhL8TEw14pjQTxnP5muwtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.