Closed
Description
I was wondering if there was any plan to add this to DRF?
I'd like to be able to do something like this:
class MyViewSet(ModelViewSet):
queryset = Users.objects.all()
@detail_route(methods=["get"], name='stats-aggregation', method_url='stats')
def statistics_aggregation(self, request, pk=None):
do_cool_things(request, pk)
And have that appear as a url in the form of /users/4/stats
and have the name be stats-aggregation
.
It looks like it would only be a matter of adding another argument to the decorator function, binding that to the function object, then adding it as a kwarg to the route constructor (rather, the replace_methodname
function).
I'd be willing to take a look at it myself, but I wanted to create an issue first to see if there's any interest or if that area of code is going to change significantly soon.