DJANGO Rest API无效语法错误

DJANGO Rest API无效语法错误,django,Django,我正在尝试使用创建Django Rest API,但出现无效语法错误。这是我的密码: url.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('',

我正在尝试使用创建Django Rest API,但出现无效语法错误。这是我的密码:

url.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),
)
Models.py

from django.db import models
class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')
    def __unicode__(self):
        return self.question    

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice = models.CharField(max_length=200)
    votes  = models.IntegerField()
    def __unicode__(self):
    return self.choice
此应用程序基于Django网站上提供的教程。它工作得很好,但一旦我实现了RESTAPI的逻辑,它就开始失败了

(r“^xml/polls/(.*?//”,xml\u poll\u资源)

我正在尝试的URL:
http://127.0.0.1:8000/xml/polls/

错误 语法错误位于/xml/polls/ 无效语法(views.py,第49行)


可能不是你想要的答案,但是我建议你看看这个Django休息框架:

你的右括号不是太多了吗?在集合中(…)谢谢..它得到了解决,但现在我得到了这个错误没有名为django_restapi.model_的模块资源
from django.db import models
class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')
    def __unicode__(self):
        return self.question    

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice = models.CharField(max_length=200)
    votes  = models.IntegerField()
    def __unicode__(self):
    return self.choice
Request Method: GET

Request URL: http://127.0.0.1:8000/xml/polls/

Django Version: 1.3.1

Exception Type: SyntaxError

Exception Value: invalid syntax (views.py, line 49)