From d2d085fba9da7fece9a68ad917f96fe2182856eb Mon Sep 17 00:00:00 2001 From: Rushil Umaretiya Date: Sun, 31 Jan 2021 11:53:51 -0500 Subject: [PATCH] fix(backend): fixed buying api --- backend/api/serializers.py | 2 +- backend/api/views.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/api/serializers.py b/backend/api/serializers.py index 443d458..c109132 100644 --- a/backend/api/serializers.py +++ b/backend/api/serializers.py @@ -39,7 +39,7 @@ class StockSerializer(serializers.ModelSerializer): class StockCreateSerializer(serializers.ModelSerializer): class Meta: model = models.Stock - fields = ('user', 'ticker', 'quantity',) + fields = ('ticker', 'quantity',) class CharitySerializer(serializers.ModelSerializer): class Meta: diff --git a/backend/api/views.py b/backend/api/views.py index af1639f..1d9ed93 100644 --- a/backend/api/views.py +++ b/backend/api/views.py @@ -38,7 +38,8 @@ class StockViewSet(ModelViewSet): def create(self, request, *args, **kwargs): - data = QueryDict.copy(request.data) + import copy + data = copy.deepcopy(request.data) data.update({'user': request.user}) serializer = StockCreateSerializer(data=request.data) serializer.is_valid(raise_exception=True) @@ -81,4 +82,4 @@ class BuyRobinhoodStock(APIView): for key, value in stonks.items(): print(key) print(value) - return Response(stonks) \ No newline at end of file + return Response(stonks)