Ant*_*esm 6 python django tastypie
我想用Tastypie框架做示例应用程序.
我将Tastypie添加到已安装的应用程序并urls.py根据需要进行了修改,添加from tastypie.api import Api.但是当我打开时http://localhost:8000/api/v1/?format=json,我得到以下异常:
异常值:没有名为常量的模块
当我跑:
pip install constants
Run Code Online (Sandbox Code Playgroud)
一切看起来都不错
Python 2.6 (and try on 2.7)
Django 1.4
Tastypie 0.10.0
Run Code Online (Sandbox Code Playgroud)
问题出在resources.pytastypie 的文件中.它有以下几行:
from django.db.models.constants import LOOKUP_SEP
Run Code Online (Sandbox Code Playgroud)
该导入仅适用于1.5+.对于django <1.5,它应该是:
from django.db.models.sql.constants import LOOKUP_SEP
Run Code Online (Sandbox Code Playgroud)
升级到1.5肯定会修复它,但对于那些不能的人来说,暂时降级tastypie或自己修复.