Exemplo n.º 1
0
 def from_dict(self, data_dict):
     """
     Overwrite the model attributes with the given data dictionary
     """
     for key in self.__dict__:
         if key in data_dict and not key == "id":
             setattr(self, key, validate_field(getattr(self, key), data_dict[key]))
Exemplo n.º 2
0
 def validate(self, data_dict):
     """
     This method will return a cleaned compatible dictionary
     """
     cleaned_dict = dict()
     for key in self.__dict__:
         if key in data_dict:
             cleaned_dict[key] = validate_field(getattr(self, key), data_dict[key])
     return cleaned_dict