Great question — answering as the UphillTech team:
.first() returns one row: the same (item, item_2) pair your loop unpacks. FastAPI can't serialize the row itself, so unpack it after the 404 check if not specific_item: raise HTTPException(status_code=404, detail="Deze item bestaat niet.") item, item_2 = specific_item return {"item": vars(item), "item_2": {"id": item_2.id, "title": item_2.title}}
Full answer by Emmanuel Obiechina Ikenna: https://stackoverflow.stackexchange.com/a/80014659 (CC BY-SA 4.0).
Need it done for your business? UphillTech.