【发布时间】:2012-09-20 14:45:17
【问题描述】:
我也有类似的想法:
def override_urls(self):
return [
url(r"^(?P<resource_name>%s)/(?P<slug>[\w\d_.-]+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
]
生成如下 URL:
/api/v1/nodes/<slug>/
一切都很好,除了self.get_resource_uri(bundle) 返回/api/v1/nodes/<id>/ 并且我无法有效地将当前 URL 与资源 URI 进行比较。
我做错了什么?
解决方案:工作代码
我在这里实施了建议的解决方案: https://github.com/ninuxorg/nodeshot/blob/refactoring/nodeshot/core/base/resources.py
欢迎任何额外的改进反馈。
【问题讨论】: