[Answered ]-How do I sort the queryset by a property's property? django

2👍

Have you tried this?

return self.request.basket.all_lines().order_by('product__upc')

0👍

How about using python’s sorted method?

sorted(self.request.basket.all_lines(), key=lambda x: x.product.upc)

Leave a comment