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.

25 lines
719 B

2 years ago
from basic_info.models import WarehouseModel
from rest_framework import serializers
class WarehouseSerializer(serializers.ModelSerializer):
"""
仓库信息的序列化器
"""
class Meta:
model = WarehouseModel
fields = '__all__'
# 用于查询结果的序列化器,因为需要显示负责人的真实名字
class WarehouseSearchSerializer(serializers.ModelSerializer):
"""
查询结果的序列化, SlugRelatedField,返回主表的某一个字段值:slug_field可以指定一个需要展示的字段
"""
leader_user = serializers.SlugRelatedField(slug_field='real_name', read_only=True)
class Meta:
model = WarehouseModel
fields = '__all__'