Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get a setting from settings file in django

I've a setting say gi in settings.py file. I've created a separate python file (i.e. I'm not using it in views) and used import statement as:

from django.conf import settings

but when I try to access settings.gi, it says that 'Settings' object has no attribute 'gi'. What's missing? :s

like image 380
wasimbhalli Avatar asked Jul 24 '12 12:07

wasimbhalli


People also ask

How do I access Django settings?

When you use Django, you have to tell it which settings you're using. Do this by using an environment variable, DJANGO_SETTINGS_MODULE . The value of DJANGO_SETTINGS_MODULE should be in Python path syntax, e.g. mysite. settings .

Where do I put settings py?

Create a settings.py file in your application's package (for example, if your application is named "myapp", put it in the filesystem directory named myapp ; the one with an __init__.py in it.


1 Answers

From the Django docs on creating your own settings states:

Setting names are in all uppercase.

Try renaming the setting to GI.

like image 115
Alasdair Avatar answered Oct 05 '22 17:10

Alasdair