Feature Request: Add hooks for CUD responses in related mixins. #7844
Replies: 2 comments
-
Hi. The standard reply here is that the mixins are so simple that you should just implement what you need. This in contrast to making them overly complex adding hooks for every possible customisation. It's not worth the API complexity, just write it inline. Cleaner. Easier to comprehend. Easier to maintain. Hope that makes sense. |
Beta Was this translation helpful? Give feedback.
-
Seconding @carltongibson - this falls into what I consider to be a complexity-feedback-loop. We'd be exchanging "customize the response message with 6 lines of code" for "customise the response message with 2 lines of code", but at a cost of adding an extra method. (Which adds a tiny bit of extra indirection and have-to-think-about-it code flow, and makes adds marginally more complexity for folks overriding the |
Beta Was this translation helpful? Give feedback.
-
There is often a scenario when you have to send a custom response after create, update, or delete operation. There is no mechanism, when using generic views, to intercept the outgoing response and replace or modify it. You just have to override the whole action method.
Example
If someone is using
CreateAPIView
and aSignupSerializer
for user signup, he might want to send back just a message instead of some resource representation. He has to override thecreate
method for this purpose.Proposal
Add new hooks in the API mixins to get the final response from view for the create, update, delete (and maybe list and retrieve also) operations. Something like this.
which will simplify the above example to
I think we can make the changes in a non-breaking manner. If this proposal is acceptable, I can contribute the code, tests, and documentation.
Beta Was this translation helpful? Give feedback.
All reactions