[Django]-Add specific method handler detail_route in Django Rest Framework

5👍

One option is to handle both GET and POST with one detail_route-decorated handler and to do additional dispatching inside the handler:

@detail_route(methods=['get', 'post'])
def photos(self, request):
    if request.method == 'POST':
        return self.new_photo(request)

    return Response(self.get_photos())

Leave a comment