Creating viewset actions on the fly #9008
-
Most of the time a view set action contains lots of boilerplate code. Please take a look at the example below.
It would be really nice if we can have this option to define a viewset actions like this:
It removes lots of boilerplate code and passes the actual duty to the seializer. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello there! |
Beta Was this translation helpful? Give feedback.
Hello there!
DRF provides some general actions itself to prevent you from doing certain things in your APIView. By using the action decorator, you can add a new custom action to your viewset, which requires specifying its complete functionality. However, in this case, you are only performing a partial_update on your user, which can be accomplished without adding a new action.