Make ProductType an OrderedModel

This commit is contained in:
imperosol
2024-12-15 18:55:09 +01:00
parent 6c8a6008d5
commit 483670e798
8 changed files with 167 additions and 100 deletions

View File

@ -71,7 +71,7 @@ class ProductController(ControllerBase):
def search_products(self, filters: Query[ProductFilterSchema]):
return filters.filter(
Product.objects.order_by(
F("product_type__priority").desc(nulls_last=True),
F("product_type__order").asc(nulls_last=True),
"product_type",
"name",
).values()
@ -95,7 +95,7 @@ class ProductController(ControllerBase):
.prefetch_related("buying_groups")
.select_related("product_type")
.order_by(
F("product_type__priority").desc(nulls_last=True),
F("product_type__order").asc(nulls_last=True),
"product_type",
"name",
)