gpt4 book ai didi

python - 没有名为常量的模块

转载 作者:太空狗 更新时间:2023-10-29 22:30:57 26 4
gpt4 key购买 nike

我想用 Tastypie 框架做示例应用。

我将 Tastypie 添加到 Installed app 并根据需要修改了 urls.py,添加了 from tastypie.api import Api。但是当我打开 http://localhost:8000/api/v1/?format=json 时,出现以下异常:

Exception Value: No module named constants

当我运行时:

pip install constants

一切正常

Python 2.6 (and try on 2.7)
Django 1.4
Tastypie 0.10.0

最佳答案

问题出在 tastypie 的 resources.py 文件中。它具有以下行:

from django.db.models.constants import LOOKUP_SEP

该导入仅适用于 1.5+。对于 django < 1.5,它应该是:

from django.db.models.sql.constants import LOOKUP_SEP

升级到 1.5 肯定会解决它,但对于那些不能的人,暂时降级 tastypie 或自行修复。

关于python - 没有名为常量的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18191221/

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