class CategorySerializers(serializers.ModelSerializer):
class Meta:
model = Category
exclude = ('desc','add_time','update_time')
class ArticleListSerializers(serializers.ModelSerializer):
category_type = CategorySerializers()
update_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S')
class Meta:
model = Article
fields = "__all__"
直接显示 category_type: ‘动漫’,而不是字典对象
Django REST framework课程视频,RESTFul API前后端分离开发
了解课程