gpt4 book ai didi

python - “函数”对象没有属性 'MY_SETTING'

转载 作者:太空狗 更新时间:2023-10-30 00:51:16 25 4
gpt4 key购买 nike

在我的 views.py 中有

from django.conf import settings

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

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

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

这是怎么回事?

最佳答案

如何导入如下设置:

from django.conf import settings as conf_settings

然后:

if some_var == conf_settings.MY_SETTING:

关于python - “函数”对象没有属性 'MY_SETTING',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13859327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com