2👍
You can use perfom_create
and perform_update
in your views
The pre_save and post_save hooks no longer exist, but are replaced
with perform_create(self, serializer) and perform_update(self,
serializer).These methods should save the object instance by calling
serializer.save(), adding in any additional arguments as required.
They may also perform any custom pre-save or post-save behavior.
Example
def perform_create(self, serializer):
# Include the owner attribute directly, rather than from request data.
instance = serializer.save(owner=self.request.user)
# Perform a custom post-save action.
send_email(instance.to_email, instance.message)
👤levi
Source:stackexchange.com