Open varunajmera0 opened 5 years ago
Error - if document._dynamic: AttributeError: 'collections.OrderedDict' object has no attribute '_dynamic'
class Conversation(DynamicDocument): poll_name = fields.StringField(required=True) poll_votes = fields.IntField(required=True)
class PollSerializer(serializers.DynamicDocumentSerializer): class Meta: model = Conversation fields = 'all'
class PollView(APIView): permission_classes = [permissions.AllowAny]
def get(self, request): serializer = PollSerializer(Conversation.objects.all(), many=True) response = {"polls": serializer.data} return Response(response, status=status.HTTP_200_OK) def post(self, request, format=None): data = request.data tag = data.pop("varun") serializer = PollSerializer(data=data) if serializer.is_valid(): poll = Conversation(**data) print("varun") poll.save() response = serializer.data return Response(response, status=status.HTTP_200_OK) return Response(serializer.data, status=status.HTTP_200_OK)
Error - if document._dynamic: AttributeError: 'collections.OrderedDict' object has no attribute '_dynamic'
class Conversation(DynamicDocument): poll_name = fields.StringField(required=True) poll_votes = fields.IntField(required=True)
class PollSerializer(serializers.DynamicDocumentSerializer): class Meta: model = Conversation fields = 'all'
class PollView(APIView): permission_classes = [permissions.AllowAny]