No module named constants

こ雲淡風輕ζ 提交于 2019-12-06 01:37:29

问题


I want to do sample application with Tastypie framework.

I added Tastypie to Installed app and modified urls.py as required, adding from tastypie.api import Api. But when I open http://localhost:8000/api/v1/?format=json, I get the following exception:

Exception Value: No module named constants

When I run:

pip install constants

everything looks ok.

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

回答1:


the problem is in the resources.py file for tastypie. It has the following line:

from django.db.models.constants import LOOKUP_SEP

That import will only work on 1.5+. For django < 1.5, it should be:

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

Upgrading to 1.5 will definitely fix it, but for those who can't, temporarily downgrade tastypie or do that fix yourself.



来源:https://stackoverflow.com/questions/18191221/no-module-named-constants

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!