0
votes

I downloaded the code from the following link and stored it in the location below,

http://django-rest-interface.googlecode.com/svn/trunk/ django-rest-interface

Location

c:/Python27/Djangoprojects/django_restapi

Project Location

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),
)

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)
) 

I get the following error when I try the URL specified below,

Error:

ImportError at /xml/polls/ No module named django_restapi.model_resource

Request Method:

GET Request URL:

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

Django Version:

1.3.1 Exception Type:

ImportError

Exception Value:

No module named django_restapi.model_resource

Exception Location:

C:\Python27\Djangoprojects\mysite..\mysite\polls\views.py in , line 1

Python Executable:

C:\Python27\python.exe

Python Version:

2.7.2

Python Path:

['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']

Server time:

Thu, 12 Jul 2012 22:31:04 -0400

How do I resolver this error?

2

2 Answers

0
votes

As from your code, Polls directory should be inside django_restapi and you should put parent of django_restapi in python path.

0
votes

Did you check the setting.py file?