2014-04-25 63 views
1

我正在學習如何使用tastypie,並使用命令sudo pip install django-tastypie安裝它。將tastypie導入項目

我想與嘗試一下:

from tastypie.resources import ModelResource 
from tastypie.resources import ALL 
from models import Article 

但是我得到:

Traceback: 
File "/Users/username/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/handlers/base.py" in get_response 
    101.     resolver_match = resolver.resolve(request.path_info) 
File "/Users/username/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/urlresolvers.py" in resolve 
    318.    for pattern in self.url_patterns: 
File "/Users/username/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/urlresolvers.py" in url_patterns 
    346.   patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
File "/Users/username/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/urlresolvers.py" in urlconf_module 
    341.    self._urlconf_module = import_module(self.urlconf_name) 
File "/Users/username/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/utils/importlib.py" in import_module 
    40.   __import__(name) 
File "/Users/username/Development/django_tutorial/bin/django_test/django_test/urls.py" in <module> 
    14.  (r'^articles/', include('article.urls')),  # links to article/urls 
File "/Users/username/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/conf/urls/__init__.py" in include 
    26.   urlconf_module = import_module(urlconf_module) 
File "/Users/username/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/utils/importlib.py" in import_module 
    40.   __import__(name) 
File "/Users/username/Development/django_tutorial/bin/django_test/article/urls.py" in <module> 
    4. from api import ArticleResource 
File "/Users/username/Development/django_tutorial/bin/django_test/article/api.py" in <module> 
    1. from tastypie.resources import ModelResource 

Exception Type: ImportError at /articles/api/article/ 
Exception Value: No module named tastypie.resources 
+0

做ü添加在Django安裝的應用程序的tastypie在settings.py –

+0

我沒有。我正在學習一個教程,並跳過了這一步驟。我會在我安裝的應用程序中添加什麼內容? – Liondancer

+1

添加tastypie,在安裝的應用程序setting.py http://django-tastypie.readthedocs.org/en/latest/tutorial.html#configuration –

回答

1

可能有兩件事情ü可能忘了:

1)添加tastypie到您的安裝應用程序setting.py

INSTALLED_APPS = (
    ..... 
    'tastypie', 


) 

或 2)U可能已經安裝了env外tastypie ..