Notas y bibliotecas funcionando
This commit is contained in:
@@ -48,10 +48,16 @@ class Model_base:
|
||||
def __json__(self) -> dict:
|
||||
"""Devuelve una representación JSON serializable (dict plano)."""
|
||||
out = {}
|
||||
|
||||
# Prevención de error: solo ejecuta si __table__ existe
|
||||
if not hasattr(self, "__table__"):
|
||||
return out
|
||||
|
||||
for attr in self.__table__.columns:
|
||||
val = getattr(self, attr.name)
|
||||
val = getattr(self, attr.name, None)
|
||||
if isinstance(val, datetime):
|
||||
out[attr.name] = val.isoformat()
|
||||
else:
|
||||
out[attr.name] = val
|
||||
return out
|
||||
|
||||
return out
|
||||
Reference in New Issue
Block a user