remove the price form sorting templory

This commit is contained in:
Parsa Nazer
2025-03-11 01:59:18 +03:30
parent d3da83d7e9
commit 91d00fadb7
+2 -1
View File
@@ -101,6 +101,7 @@ class AllProductsView(APIView):
"Sort results by one of the following fields:\n" "Sort results by one of the following fields:\n"
"`name`, `-name`, `price`, `-price`, `created_at`, `-created_at`." "`name`, `-name`, `price`, `-price`, `created_at`, `-created_at`."
"\nPrefix with `-` for descending order." "\nPrefix with `-` for descending order."
"remove the price form sorting templory "
), ),
required=False, required=False,
type=OpenApiTypes.STR, type=OpenApiTypes.STR,
@@ -179,7 +180,7 @@ class AllProductsView(APIView):
# Sorting # Sorting
sort_by = request.query_params.get('sort', None) sort_by = request.query_params.get('sort', None)
if sort_by in ['name', '-name', 'price', '-price', 'created_at', '-created_at']: if sort_by in ['name', '-name', 'created_at', '-created_at']:
products = products.order_by(sort_by) products = products.order_by(sort_by)
else: else:
products = products.order_by('name') products = products.order_by('name')