Issue
For example, here is my all data : IMG1
My viewset :
class CardCheckViewSet(viewsets.ModelViewSet):
serializer_class = CardCheckSerializer
queryset = CardCheck.objects.all()
def create(self, request):
for obj in CardCheck.objects.all():
print(obj)
return super().create(request)
And here is the data after I post something in it: IMG2
There should be 4 objects but this is what I got printed :
CardCheck object (30)
CardCheck object (34)
CardCheck object (44)
There is not the posted data as you see. Why is that data doesnt appears in here? What can I do about it?
Solution
You try to print the CardCheck
items before adding a new one. This way should work:
class CardCheckViewSet(viewsets.ModelViewSet):
serializer_class = CardCheckSerializer
queryset = CardCheck.objects.all()
def create(self, request):
new_obj = super().create(request)
for obj in CardCheck.objects.all():
print(obj)
return new_obj
Answered By - Yevgeniy Kosmak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.