You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Product():
name = models.CharField(max_length=128)
...
customers = models.ManyToManyField('Person', through="TreatmentRun2Person", blank=True)
When we run a default query on products, we get the expected results. For example, the customer object with id=13 associated with product id=5 is correctly returned.
However, when we run a custom query, ie /api/products/?&query={attributes,created_at,persons{id,first_name,last_name},suppliers{id,name}} then for product 5, the customer object returned is 13 repeated 3 times (for each time it's associated with a product). Better demonstrated:
Let's say we have 2 tables and a many_to_many table: \
product
customer
product_2_customer
Our Product Serializer looks something like:
Our Customer Model looks something like:
When we run a default query on products, we get the expected results. For example, the customer object with id=13 associated with product id=5 is correctly returned.
However, when we run a custom query, ie
/api/products/?&query={attributes,created_at,persons{id,first_name,last_name},suppliers{id,name}}
then for product 5, the customer object returned is 13 repeated 3 times (for each time it's associated with a product). Better demonstrated:This is not the behavior we would expect and we were wondering why the behavior changes when the query filter is applied? Thank you.
The text was updated successfully, but these errors were encountered: