Multiples @detail_route with the same url_path
#4264
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR allows you to have multiple class method in your ViewSet each one with the same 'url_path' but different HTTP method using
@detail_route
, e.g.:Example code
After creating a django-rest-project, this is all the code needed to test with simple
curl
hits:GET to my endpoint:
POST to my endpoint:
Using the original
routers.py
file (from master)GET to the endpoint:
POST to the endpoint
Notes
I ran the tests using
tox
and some of them are not passing. As I'm new as collaborator of drf, before to start going deep into the code and try to fix these and make all the test pass (that will take me some time to research), I would like to know if the idea is something that you consider at least valid.I mean, maybe there is something that I'm not seeing or this should be done in another way.
What do you think?