我从以下链接下载了代码并将其存储在下面的位置,
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 的模块
请求方法:
获取请求网址:
http://127.0.0.1:8000/xml/polls/
Django 版本:
1.3.1 异常类型:
导入错误
异常值:
没有名为 django_restapi.model_resource 的模块
异常位置:
C:\Python27\Djangoprojects\mysite..\mysite\polls\views.py 在第 1 行
Python可执行文件:
C:\Python27\python.exe
蟒蛇版本:
2.7.2
蟒蛇路径:
['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-赢', '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
如何解决此错误?