次のリンクからコードをダウンロードし、以下の場所に保存しました。
http://django-rest-interface.googlecode.com/svn/trunk/django-rest-interface _
位置
c:/Python27/Djangoprojects/django_restapi
プロジェクトの場所
c:/Python27/Djangoprojects/mysite/polls
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),
)
ビュー.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/ に ImportError という名前のモジュールがありません django_restapi.model_resource
リクエスト方法:
GET リクエスト URL:
http://127.0.0.1:8000/xml/polls/
ジャンゴのバージョン:
1.3.1 例外タイプ:
インポート エラー
例外値:
django_restapi.model_resource という名前のモジュールはありません
例外の場所:
C:\Python27\Djangoprojects\mysite..\mysite\polls\views.py の 1 行目
Python 実行可能ファイル:
C:\Python27\python.exe
Python バージョン:
2.7.2
Python パス:
['C:\Python27\Djangoprojects\mysite', 'C:\Python27\lib\site-packages\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\site-packages', 'C:\Python27\lib\site-packages\wx-2.8-msw-unicode']
サーバー時間:
2012 年 7 月 12 日 (木) 22:31:04 -0400
このエラーを解決するにはどうすればよいですか?