We're building an API with Django Rest Framework, and our clients want it to have this endpoint:
Method: POST
URL: api/v1/application/<id>
It's basically an update endpoint but with POST instead of PUT.
I already have a viewset for this model, and we're using the create, list, and retrieve actions.
So, one thing I can do is to allow POST for update actions in Django Rest Framework, but I haven't found how to do that. Also, I can define a custom action like this:
@action(methods=['post'], detail=True)
def update_status(self, request, pk=None):
# some code
The problem is this routes to application/<id>/update_status, I can change the route by passing the url_path parameter, but if it's None or empty it just defaults to update_status again.
I can also just define this endpoint in a different view and route manually, but that's a worse solution in my opinion, it would be nice to have it in the viewset I already have.
Thanks.