Created
February 27, 2021 15:46
-
-
Save NurElHuda/c49007a23072e57ad5efa7488246b44c to your computer and use it in GitHub Desktop.
Django serializer: generic update function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update(self, instance, validated_data): | |
for key, value in validated_data.items(): | |
setattr(instance, key, value) | |
instance.save() | |
return instance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment