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"
|
||||
"`name`, `-name`, `price`, `-price`, `created_at`, `-created_at`."
|
||||
"\nPrefix with `-` for descending order."
|
||||
"remove the price form sorting templory "
|
||||
),
|
||||
required=False,
|
||||
type=OpenApiTypes.STR,
|
||||
@@ -179,7 +180,7 @@ class AllProductsView(APIView):
|
||||
|
||||
# Sorting
|
||||
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)
|
||||
else:
|
||||
products = products.order_by('name')
|
||||
|
||||
Reference in New Issue
Block a user