class ProductManager models Manager def active self return self filter

1
2
3
4
5
class ProductManager(models.Manager):
def active(self):
return self.filter(active=True).order_by('unit_price')
def related_items(self):
return [item for price, item in sorted((item.unit_price, item) for item in self.related_items.all())