From here,
I need to update my existing document data using from_json
.
When I am using from_json
like
>> user = User.objects(pk=2).first()
>> print user.to_json()
above shows
>> {"_id": 1, "_cls": "User", "name": "OldName"}
now I update existing user
object
>> user = user.from_json(json.dumps({"_id": 1, "_cls": "User", "name": "NewName"}))
>> user.save()
>> print user.to_json()
it shows
>> {"_id": 1, "_cls": "User", "name": "NewName"}
But it cannot update in DB.
Again I querying same user
it shows
>> {"_id": 1, "_cls": "User", "name": "OldName"}
My Question is how can I update existing data using document object method from_json
?