fix(backend): fixed buying api

This commit is contained in:
Rushil Umaretiya 2021-01-31 11:53:51 -05:00
parent 2e51f0904f
commit d2d085fba9
2 changed files with 4 additions and 3 deletions

View File

@ -39,7 +39,7 @@ class StockSerializer(serializers.ModelSerializer):
class StockCreateSerializer(serializers.ModelSerializer): class StockCreateSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = models.Stock model = models.Stock
fields = ('user', 'ticker', 'quantity',) fields = ('ticker', 'quantity',)
class CharitySerializer(serializers.ModelSerializer): class CharitySerializer(serializers.ModelSerializer):
class Meta: class Meta:

View File

@ -38,7 +38,8 @@ class StockViewSet(ModelViewSet):
def create(self, request, *args, **kwargs): def create(self, request, *args, **kwargs):
data = QueryDict.copy(request.data) import copy
data = copy.deepcopy(request.data)
data.update({'user': request.user}) data.update({'user': request.user})
serializer = StockCreateSerializer(data=request.data) serializer = StockCreateSerializer(data=request.data)
serializer.is_valid(raise_exception=True) serializer.is_valid(raise_exception=True)
@ -81,4 +82,4 @@ class BuyRobinhoodStock(APIView):
for key, value in stonks.items(): for key, value in stonks.items():
print(key) print(key)
print(value) print(value)
return Response(stonks) return Response(stonks)