在views.py
我有
from django.conf import settings
def site_view(request):
...
if some_var == settings.MY_SETTING:
...
值MY_SETTING
在settings.py
中定义。但是,当我尝试加载视图时出现以下错误:
Exception Type: AttributeError
Exception Value: 'function' object has no attribute 'MY_SETTING'
发生了什么事?
答案 0 :(得分:8)
如何导入以下设置:
from django.conf import settings as conf_settings
然后:
if some_var == conf_settings.MY_SETTING: