diff --git a/sijapi/classes.py b/sijapi/classes.py index 332f579..04eff65 100644 --- a/sijapi/classes.py +++ b/sijapi/classes.py @@ -489,7 +489,10 @@ class Location(BaseModel): datetime: lambda dt: dt.isoformat(), } - + def model_dump(self): + data = self.dict() + data["datetime"] = self.datetime.isoformat() if self.datetime else None + return data class Geocoder: diff --git a/sijapi/routers/gis.py b/sijapi/routers/gis.py index 8d8b937..cb0daf0 100644 --- a/sijapi/routers/gis.py +++ b/sijapi/routers/gis.py @@ -548,11 +548,11 @@ async def get_last_location_endpoint() -> JSONResponse: if this_location: location_dict = this_location.model_dump() - location_dict["datetime"] = this_location.datetime.isoformat() return JSONResponse(content=location_dict) else: raise HTTPException(status_code=404, detail="No location found before the specified datetime") + @gis.get("/locate/{datetime_str}", response_model=List[Location]) async def get_locate(datetime_str: str, all: bool = False): try: