r/FastAPI • • Dec 31 '24

Question Real example of many-to-many with additional fields

Hello everyone,

Over the past few months, I’ve been working on an application based on FastAPI. The first and most frustrating challenge I faced was creating a many-to-many relationship between models with an additional field. I couldn’t figure out how to handle it properly, so I ended up writing a messy piece of code that included an association table and a custom validator for serialization...

Is there a clear and well-structured example of how to implement a many-to-many relationship with additional fields? Something similar to how it’s handled in the Django framework would be ideal.

20 Upvotes

5 comments sorted by

View all comments

Show parent comment

2

u/PhilShackleford Dec 31 '24

I thought sqlmodel was a wrapper for alchemy that works well for a lot of things with the notable exception of asyc?