我想添加Django应用的文档
1.我使用的是休息框架mongoengine
- OpenAPI 3.0,drf-壮观的 Swagger
- 型号:**
from mongoengine import *
class Service(Document):
student_id = StringField(required=True)
name = StringField(max_length=50)
age = IntField()
- 串行化程序:**
from Service.models import Service
from rest_framework_mongoengine import serializers as mongoserializers
class ServiceSerializer(mongoserializers.DocumentSerializer):
class Meta:
model = Service
fields = '__all__'
- 浏览次数:**
import mongoengine
from .models import Service
from rest_framework import generics
from .serializers import ServiceSerializer
from .docs import list_service, create_service, update_service, delete_service
from rest_framework_mongoengine.viewsets import ModelViewSet as MongoModelViewSet
mongoengine.connect(db='Ecommerce', host='localhost:27017')
@create_service()
class CreateServiceAPI(generics.CreateAPIView):
queryset = Service.objects.all()
serializer_class = ServiceSerializer
我创建了文档,但当我执行文档中的任何端点时,会发生此错误
"属性错误:"QuerySet"对象没有属性"model"
任何人都能帮我解决这个问题
1条答案
按热度按时间bnl4lu3b1#
更改模型以添加字段: