Suppose I have a model like this:
class Book(models.Model):
num_pages = ...
author = ...
date = ...
Can I create a dictionary,
Use ** for creating a new model. Loop through the dictionary and use setattr() in order to update an existing model.
From Tom Christie's Django Rest Framework
https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/serializers.py
for attr, value in validated_data.items():
setattr(instance, attr, value)
instance.save()