Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named constants

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
like image 474
Antaresm Avatar asked Aug 12 '13 15:08

Antaresm


1 Answers

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.

like image 104
KVISH Avatar answered Oct 11 '22 00:10

KVISH