all products end point debug
This commit is contained in:
@@ -142,9 +142,9 @@ class AllProductsView(APIView):
|
|||||||
)
|
)
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
try:
|
try:
|
||||||
category_id = int(request.query_params.get('category', None))
|
category_id = request.query_params.get('category', None)
|
||||||
if category_id:
|
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)
|
products = ProductModel.objects.filter(category=sub_category)
|
||||||
else:
|
else:
|
||||||
products = ProductModel.objects.all()
|
products = ProductModel.objects.all()
|
||||||
|
|||||||
Reference in New Issue
Block a user