http_method_names and @action decorator #8444
Unanswered
variable
asked this question in
Question & Answer
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I had a task to add an extra action to an existing
ModelViewSet
view, to simplify the example:when I make a delete method call to
/user/123/delete_profile
, I get 405 Method not allowed, however, if I add delete to http_method_names as below, it works fine.This is because
delete
is not inhttp_method_names
. But havingdelete
inhttp_method_names
it implicitly allows delete operation onUser
model, which is wrong.I am in two minds:
1st) This is by design that a
ModelViewSet
should only manage ONE model2nd) But then my above case sort of makes sense to delete related model as well
Could someone please provide some guidance on this matter? Should
method
inside@action
override thehttp_method_names
?Relative SO question https://stackoverflow.com/questions/71673257/django-rest-framework-method-in-action-decorator-needs-be-specified-in-class-htt
Beta Was this translation helpful? Give feedback.
All reactions