'function'对象没有属性'MY_SETTING'

时间:2012-12-13 11:56:08

标签: python django

views.py我有

from django.conf import settings

  def site_view(request):
    ...
    if some_var == settings.MY_SETTING:
  ...

MY_SETTINGsettings.py中定义。但是,当我尝试加载视图时出现以下错误:

Exception Type:    AttributeError
Exception Value:   'function' object has no attribute 'MY_SETTING'

发生了什么事?

1 个答案:

答案 0 :(得分:8)

如何导入以下设置:

from django.conf import settings as conf_settings

然后:

if some_var == conf_settings.MY_SETTING: