enabled custom serializers in my_ endpoints
This commit is contained in:
@@ -6,7 +6,6 @@ from functools import reduce
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.conf import settings
|
||||
from django.core import serializers
|
||||
from django.db.models import Q
|
||||
|
||||
# Create your views here.
|
||||
@@ -46,8 +45,8 @@ class ProductViewSet(viewsets.ModelViewSet):
|
||||
@permission_classes([IsAuthenticated,])
|
||||
def my_products(request):
|
||||
qs = Product.objects.filter(creator=request.user)
|
||||
data = serializers.serialize('json', qs)
|
||||
return Response(data=data)
|
||||
product_serializer = ProductSerializer(qs)
|
||||
return Response(data=product_serializer.data)
|
||||
|
||||
|
||||
@api_view(['POST',])
|
||||
@@ -167,7 +166,7 @@ def product_search(request):
|
||||
result_set.add(item)
|
||||
|
||||
# serialize and respond
|
||||
data = serializers.serialize('json', result_set)
|
||||
return Response(data=data)
|
||||
product_serializer = ProductSerializer(result_set)
|
||||
return Response(data=product_serializer.data)
|
||||
except Exception as e:
|
||||
return Response({"errors": {"details": str(type(e))}})
|
||||
|
||||
Reference in New Issue
Block a user