You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
475 B
20 lines
475 B
2 years ago
|
from rest_framework import serializers
|
||
|
from article.models import Article
|
||
|
|
||
|
# 返回文章列表或创建一篇文章
|
||
|
class ArticleListSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = Article
|
||
|
fields = [
|
||
|
'id',
|
||
|
'title',
|
||
|
'created',
|
||
|
'body',
|
||
|
]
|
||
|
|
||
|
# 返回文章详情
|
||
|
class ArticleDetailSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = Article
|
||
|
fields = '__all__'
|