hello,
Good morning, I have this python function on file called base_model.py
here an example for accessing to function to_dict inside.
My question is: how can I acces to updated_at or to created_at?
Thanks
Good morning, I have this python function on file called base_model.py
Code
def to_dict(self):
""" : returns a dictionary all keys/values of dict of the instance"""
ret_dict = self.__dict__.copy()
ret_dict["created_at"] = self.created_at.isoformat()
ret_dict["updated_at"] = self.updated_at.isoformat()
ret_dict["__class__"] = self.__class__.__name__
return ret_dicthere an example for accessing to function to_dict inside.
Code
>>>from base_model import BaseModel
>>> dic = BaseModel()
>>> mdic = dic.to_dict()
>>> print(dic) #prfint everything the funcion inside
>>>
[BaseModel] (d130a170-ead3-4942-b01c-caffdd688e34) {'id': 'd130a170-ead3-4942-b01c-caffdd688e34', 'created_at': datetime.datetime(2019, 11, 9, 10, 51, 30, 386593), 'updated_at': datetime.datetime(2019, 11, 9, 10, 51, 30, 386607)}Code
>>>print(mdic) #print created_at and updated_at y the class name
{'id': 'd130a170-ead3-4942-b01c-caffdd688e34', 'created_at': '2019-11-09T10:51:30.386593', 'updated_at': '2019-11-09T10:51:30.386607', '__class__': 'BaseModel'}My question is: how can I acces to updated_at or to created_at?
Thanks

