Id null в API django с помощью mongo и djongo

Мне нужна помощь. Мой API получает "id": null вместо uuid, заданного в mongoDB.

Вот результаты :

Результат в RestER

Result в NoSqlManager

А вот мой код :

serializers.py

from testapp.models import Test

class TestSerializer(serializers.ModelSerializer):
    class Meta:
        model = Test
        fields=fields='__all__'

models.py


class Test(models.Model):
    testChar = models.CharField(max_length=255)
    testTwo = models.CharField(max_length=255)

views.py

from django.views.decorators.csrf import csrf_exempt
from rest_framework.parsers import JSONParser
from django.http.response import JsonResponse


# Create your views here.
from testapp.models import Test
from testapp.serializers import TestSerializer


@csrf_exempt
def testApi(request,id=0):
    if request.method == 'GET':
        test = Test.objects.all()
        test_serializer = TestSerializer(test,many=True)
        return JsonResponse(test_serializer.data,safe=False)
    elif request.method == 'POST':
        test_data = JSONParser().parse(request)
        test_serializer = TestSerializer(data=test_data)
        if test_serializer.is_valid():
            test_serializer.save()
            return JsonResponse("Added successfully", safe=False)
        return JsonResponse("Failed to Add",safe=False)
    elif request.method == 'PUT':
        test_data=JSONParser().parse(request)
        test=Test.objects.get(TestId=test_data['TestId'])
        test_serializer = TestSerializer(test,data=test_data)
        if test_serializer.is_valid():
            test_serializer.save()
            return JsonResponse("Update successfully", safe=False)
        return JsonResponse("Failed to Update")
    elif request.method == 'DELETE':
        test=Test.objects.get(TestId=id)
        test.delete()
        return JsonResponse("Deleted successfully", safe=False)
Вернуться на верх