all products end point debug

This commit is contained in:
Parsa Nazer
2025-01-23 08:12:44 +03:30
parent 2bbf37a327
commit 318efb6852
+2 -2
View File
@@ -142,9 +142,9 @@ class AllProductsView(APIView):
)
def get(self, request):
try:
category_id = int(request.query_params.get('category', None))
category_id = request.query_params.get('category', None)
if category_id:
sub_category = get_object_or_404(SubCategoryModel, pk=category_id)
sub_category = get_object_or_404(SubCategoryModel, pk=int(category_id))
products = ProductModel.objects.filter(category=sub_category)
else:
products = ProductModel.objects.all()