Unable to get a setting from settings file in django

最后都变了- 提交于 2020-01-03 07:20:14

问题


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


回答1:


From the Django docs on creating your own settings states:

Setting names are in all uppercase.

Try renaming the setting to GI.




回答2:


The project must be added on the PYTHONPATH and the DJANGO_SETTINGS_MODULE has to be defined. Please refer to the commands mentioned below.

export PYTHONPATH=PATH_OF_PROJECT
export DJANGO_SETTINGS_MODULE=settings


来源:https://stackoverflow.com/questions/11631194/unable-to-get-a-setting-from-settings-file-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!