Reputation: 5231
Here's the url I have for Resource's list:
url(r'^(?P<resource_name>%s)/stats%s$' % (
self._meta.resource_name, trailing_slash()),
self.wrap_view('dispatch_list'), name='api_dispatch_regions_stats')
I need to do the same thing for the detail, something like:
url(r'^(?P<resource_name>%s)/(?P<pk>)/stats%s$' % (
self._meta.resource_name, self._meta.pk trailing_slash()),
self.wrap_view('dispatch_list'), name='api_dispatch_regions_stats')
so I would be able to do something like:
def alter_detail_data_to_serialize(self, request, data):
if 'stats' in request.path:
do_something()
return data
Upvotes: 0
Views: 94
Reputation: 824
Normally you would do
url(r'^(?P<resource_name>%s)/(?P<pk>\d+)/stats%s$' % (self._meta.resource_name, trailing_slash()),
self.wrap_view('dispatch_list'),
name='api_dispatch_regions_stats')
and Django cares for the rest but I am not sure what you really want to do.
Upvotes: 1