[Answer]-Django Tastypie – using slug IN ADDITION to Id

1👍

You can always have 2 targets for the same view
Also, slugs never have . and _

prepend_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(r"^(?P<resource_name>%s)/(?P<id>[\d]+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),

    ]

Leave a comment