Мое текущее решение выглядит следующим образом:
Код: Выделить всё
class DocumentPublic(DocumentBase):
id: int
doc_type: int
doc_type_name: str | None = None
# ...
def __init__(self, **data):
super().__init__(**data)
self.doc_type_name = get_doc_type_name(self.doc_type)
Код: Выделить всё
return [DocumentPublic(**document.dict() for document in documents]
Спасибо за помощь.
Подробнее здесь: https://stackoverflow.com/questions/792 ... onse-class