flask-peewee icon indicating copy to clipboard operation
flask-peewee copied to clipboard

Many to Many Relationships with Api

Open AlJohri opened this issue 10 years ago • 0 comments

Is there an easy way to implement either many to many relationships or custom filters in the peewee API?

For example if I have a speech model and a topic model which have a many to many relationship, I'd like to be able to use the API to get speeches with a topic id of 1.

Ideally: example.com/api/speeches/?topic=1

This can easily be done for many to one or one to many relationships because the relationship is expressed within the Peewee model, but the many to many is expressed using a separate join table.

https://github.com/coleifer/peewee/blob/master/docs/peewee/models.rst#implementing-many-to-many

AlJohri avatar Apr 04 '14 00:04 AlJohri