[Answered ]-Define an order for ManyToManyField by through model field with Django

2👍

Use a double underscore to order_by a related field:

Product.objects.order_by("b_products__product_b_rank")

Edit:

product.product_a.order_by('product_b_rank')
product.product_b.order_by('product_a_rank')

Leave a comment