You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SIDE NOTE: I've read through CONTRIBUTING.md, and it suggests "it's a good idea to make pull requests early on". It also doesn't say it is mandatory to also create an issue, write to the mailing list, etc. Following the suggestions from CONTRIBUTING, I submitted a PR #2820, attaching a detailed comment with a description of what I'm trying to achieve. But having been ignored for 5 days already makes me think just submitting a PR is not actually enough, so I decided to created an accompanying issue (this issue) as well.
Back to the subject. Currently, if I need an ad hoc route to handle several HTTP methods I'm expected to define a single method in a view set, and then explicitly check for the value of the request.method to decide what code path to choose.
Example. Lets assume I have a UserViewSet similar to the one from the DRF's documentation. I'd like a single sub-URL to be used for both setting and resetting (deleting) the user's password. Currently, I can do this like follows:
This Pull Request allows to define several decorated viewset methods with the same url_path but different methods, and lets DRF route requests to these methods automatically based on both URL the HTTP method, just like with predefined list, get, update etc. viewset methods. In the client side code this will look like follows:
PR #2820 makes this possible in (as far as I can see) backward-compatible manner. If the proposed change is acceptable in general, I'll extend the PR with unit-tests.
Regards,
Andriy.
The text was updated successfully, but these errors were encountered:
SIDE NOTE: I've read through CONTRIBUTING.md, and it suggests "it's a good idea to make pull requests early on". It also doesn't say it is mandatory to also create an issue, write to the mailing list, etc. Following the suggestions from CONTRIBUTING, I submitted a PR #2820, attaching a detailed comment with a description of what I'm trying to achieve. But having been ignored for 5 days already makes me think just submitting a PR is not actually enough, so I decided to created an accompanying issue (this issue) as well.
Back to the subject. Currently, if I need an ad hoc route to handle several HTTP methods I'm expected to define a single method in a view set, and then explicitly check for the value of the
request.method
to decide what code path to choose.Example. Lets assume I have a
UserViewSet
similar to the one from the DRF's documentation. I'd like a single sub-URL to be used for both setting and resetting (deleting) the user's password. Currently, I can do this like follows:This Pull Request allows to define several decorated viewset methods with the same
url_path
but differentmethods
, and lets DRF route requests to these methods automatically based on both URL the HTTP method, just like with predefinedlist
,get
,update
etc. viewset methods. In the client side code this will look like follows:PR #2820 makes this possible in (as far as I can see) backward-compatible manner. If the proposed change is acceptable in general, I'll extend the PR with unit-tests.
Regards,
Andriy.
The text was updated successfully, but these errors were encountered: