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.
19 lines
475 B
19 lines
475 B
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__'
|
|
|