r/FastAPI • u/pottymouth_dry • 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.
View all comments
Show parent comment
3
u/sexualrhinoceros Dec 31 '24
I’d be remiss to not mention that while these docs are helpful, SQLModel is still not in a place where it’s suggested to be used. Just use SQLAlchemy.
There is still no async support nor is there migrations or any support for them out of the box.