I've a model named Conversation
with some fields that includes date_created
and date_updated
as DateTimePropterty
with auto_now_add
and auto_now
.
If I update the model using put()
method, date_updated
field is getting updated.
But when I use the put_async
method, the value in the date_updated
field is not updating.
And I also have the test case using Python's unittest.Testcase
, there it works fine.
Note: It works when I use put_async().get_result()
.
Sample model class:
class Conversation(ndb.Model):
participants = ndb.StringProperty(repeated=True)
conversation_name = ndb.StringProperty()
date_created = ndb.DateTimeProperty(required=True, auto_now_add=True)
date_updated = ndb.DateTimeProperty(required=True, auto_now=True)
@staticmethod
def update_conversation_date_by_id(conversation_id):
conversation = Conversation.get_by_id(conversation_id) if conversation_id else None
if conversation is None:
raise CannotFindEntity("Given conversation_id is not found")
else:
conversation.put_async().get
return conversation