serializers
from rest_framework import serializers
class SerializerClass(serializers.ModelSerializer):
class Meta:
model = ModelClass
# 1.序列化指定字段
fields = ('id', 'name', 'sort',)
# 2.序列化全部所有的字段
# fields = '__all__'
# 3. 序列化除了user以外的所有字段
# exclude = ('user',)
# 只读字段
read_only_field = ('id', 'name', 'sort',)
标签:__,serializers,rest,Django,framework,序列化,id
From: https://www.cnblogs.com/congxinglong/p/17148038.html