from pydantic import BaseModel from typing import List, Dict, Optional from datetime import datetime class Response(BaseModel): config_id: str rating_v: int rating_p0: int rating_p1: int comment: Optional[str] timestamp: str class Feedback(BaseModel): id: int user_id: str time_stamp: datetime responses: List[Response] # Override the method to serialize datetime def dict(self, *args, **kwargs): feedback_data = super().dict(*args, **kwargs) feedback_data['time_stamp'] = self.time_stamp.isoformat() # Convert datetime to ISO string return feedback_data