2012-07-14 40 views
0

我下載從以下鏈接代碼並將其存儲在下面的位置,DJANGO RESTAPI - 無模塊發現錯誤

http://django-rest-interface.googlecode.com/svn/trunk/ Django的休息接口

位置

C:/ Python27/Djangoprojects/django_restapi

項目位置

C:/ Python27/Djangoprojects/mysite的/民調

URLS.py

from django.conf.urls.defaults import * 
from polls.views import * 

# Uncomment the next two lines to enable the admin: 
from django.contrib import admin 
admin.autodiscover() 

urlpatterns = patterns('', 
    (r'^polls/$',index), 
    (r'^polls/(?P<poll_id>\d+)/$',detail), 
    (r'^polls/(?P<poll_id>\d+)/results/$',results), 
    (r'^polls/(?P<poll_id>\d+)/vote/$',vote), 
    (r'^admin/', include(admin.site.urls)), 
    (r'^xml/polls/(.*?)/?$',xml_poll_resource), 
) 

views.py

from django_restapi.model_resource import Collection 
from django_restapi.responder import XMLResponder 
from django_restapi.responder import * 
from django_restapi_tests.polls.models import Poll, Choice 



xml_poll_resource = Collection( 
queryset = Poll.objects.all(),  
permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),  
responder = XMLResponder(paginate_by = 10) 
) 

我收到以下錯誤,當我嘗試以下指定的URL,

錯誤:

導入錯誤的/ xml/polls/ 沒有名爲django_restapi.model_resource的模塊

請求方法:

GET 請求URL:

http://127.0.0.1:8000/xml/polls/ 

Django的版本:

1.3.1 異常類型:

導入錯誤

異常值:

無模塊命名django_restapi.model_resource

異常地點:

C:\ Python27 \ Djangoprojects \ mysite的.. \ mysite的\調查\ views.py中,1號線

Python的可執行文件:

C:\ Python27 \ python.exe

Python版本:

2.7.2

Python的路徑:

[ 'C:\ Python27 \ Djangoprojects \ mysite的', 「C:\ Python27 \ LIB \站點包\ setuptools的-0.6c11-py2.7.egg ', 'C:\ Python27 \ lib \ site-packages \ django_db_log-2.2.1-py2.7.egg', 'C:\ Python27', 'c:\ Python27 \ lib \ site-packages \ django \ bin \ django-admin.py', 'c:\ mysql', 'c:\ pythonpath \ djangoprojects \ django_restapi', 'C:\ Windows \ system32 \ python27。zip', 'C:\ Python27 \ DLLs', 'C:\ Python27 \ lib', 'C:\ Python27 \ lib \ plat-win', 'C:\ Python27 \ lib \ lib-tk' , 'C:\ Python27 \ LIB \站點包', 'C:\ Python27 \ LIB \站點包\ WX-2.8-MSW-unicode的']

服務器時間:

星期四, 2012年7月12日22時31分04秒-0400

如何解決此錯誤?

回答

0

從你的代碼,Polls目錄應該在django_restapi裏面,你應該把django_restapi的父項放在python路徑中。

相關問題