def update_model(old_model, new_model):
"""Updates a model.
For all fields that are set in new_model, copy them into old_model.
Args:
old_model: The ndb model object retrieved from the datastore.
new_model_dict: A json object containing the new values.
"""
for k, v in new_model.to_dict().iteritems():
if type(getattr(type(new_model), k)) != ndb.ComputedProperty and v is not None:
setattr(old_model, k, v)
评论列表
文章目录