In my views.py
I have
在我的views.py中我有
from django.conf import settings
def site_view(request):
...
if some_var == settings.MY_SETTING:
...
The value MY_SETTING
is defined in settings.py
. However I get the following error when I try and load the view:
值MY_SETTING在settings.py中定义。但是,当我尝试加载视图时,我收到以下错误:
Exception Type: AttributeError
Exception Value: 'function' object has no attribute 'MY_SETTING'
What's going on?
这是怎么回事?
1 个解决方案
#1
8
How about importing settings like:
如何导入设置如下:
from django.conf import settings as conf_settings
then:
if some_var == conf_settings.MY_SETTING:
#1
8
How about importing settings like:
如何导入设置如下:
from django.conf import settings as conf_settings
then:
if some_var == conf_settings.MY_SETTING: