教程模块
This commit is contained in:
28
tutorial/schemas.py
Normal file
28
tutorial/schemas.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from ninja import Schema, ModelSchema
|
||||
from typing import List, Optional
|
||||
from .models import Tutorial
|
||||
|
||||
|
||||
class TutorialSlim(Schema):
|
||||
display: str
|
||||
title: str
|
||||
is_public: bool
|
||||
|
||||
|
||||
class TutorialAll(ModelSchema):
|
||||
class Meta:
|
||||
model = Tutorial
|
||||
fields = "__all__"
|
||||
|
||||
|
||||
class TutorialReturn(Schema):
|
||||
total: int
|
||||
list: List[TutorialSlim]
|
||||
first: Optional[TutorialAll]
|
||||
|
||||
|
||||
class TutorialIn(Schema):
|
||||
display: str
|
||||
title: str
|
||||
content: str
|
||||
is_public: bool = False
|
||||
Reference in New Issue
Block a user