Allow custom success status code on CreateModelMixin #8040
Replies: 2 comments
-
So, the trade-off in this kind of change is that it's adding (a little bit of) extra complexity and indirection, in exchange for (a little bit of) extra convenience when overriding one particular bit of behaviour. From my experience, when weighing up this kind of trade-off, these kind of "override hooks" generally add up to a net negative. |
Beta Was this translation helpful? Give feedback.
-
I understand, but for the future, and most async function coming in django 3, it's a great improvement for the future... if django-rest allow to support async in the future, to maintain conformity of status code, it necessary to select status in sync/async functions, this allow this (course, if not create a separate view for this) |
Beta Was this translation helpful? Give feedback.
-
Hi
On my enterprise, we use generics view for a lot of solution,
Ex: generate a token and send to email, receive a data and put on QUEUE and another things (in most cases async operations)
For this reason in most cases the default status code is not befitting for trigged action.
Ex: put data to QUEUE using a
CreateAPIView
be default return a 201 (OK) status code.but REST standard use 202 (Accepted) status code to data received but not processed yet
My suggestion is change Generic Mixins hard code status
Ex:
CreateModelMixin
to
what do you think? it makes sense?
Beta Was this translation helpful? Give feedback.
All reactions