【发布时间】:2013-11-07 11:40:52
【问题描述】:
我正在尝试通过 Django-tastypie 中的prepend_urls() 功能添加访问同一 ResourceModel 的两种不同方法,但第二个 url 永远不起作用。
这是我的代码:
class UserResource(ModelResource):
class Meta:
...
my_id_uri_name = 'my_id'
name_uri_name = 'name'
def prepend_urls(self):
return [
url(
r"^(?P<resource_name>%s)/(?P<my_id>[\w\d_.-]+)/$"
% self._meta.resource_name, self.wrap_view('dispatch_detail'),
name="api_dispatch_detail_my_id"),
url(
r"^(?P<resource_name>%s)/(?P<name>[\w\d_.-]+)/$"
% self._meta.resource_name, self.wrap_view('dispatch_detail'),
name="api_dispatch_detail_name"),
]
我找不到任何有关在此处添加附加 URL 的有用资源。我错过了一些琐碎的事情吗?
【问题讨论】:
标签: python django api tastypie