remove the price form sorting templory
This commit is contained in:
@@ -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')
|
||||||
|
|||||||
Reference in New Issue
Block a user