386 Star 2.6K Fork 1.1K

GVPGreaterWMS/GreaterWMS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
serializers.py 4.89 KB
一键复制 编辑 原始数据 按行查看 历史
Elvis.Shi 提交于 2022-04-03 09:49 . V 2.1.3
from rest_framework import serializers
from .models import ListModel
from utils import datasolve
class CustomerGetSerializer(serializers.ModelSerializer):
customer_name = serializers.CharField(read_only=True, required=False)
customer_city = serializers.CharField(read_only=True, required=False)
customer_address = serializers.CharField(read_only=True, required=False)
customer_contact = serializers.CharField(read_only=True, required=False)
customer_manager = serializers.CharField(read_only=True, required=False)
customer_level = serializers.IntegerField(read_only=True, required=False)
creater = serializers.CharField(read_only=True, required=False)
create_time = serializers.DateTimeField(read_only=True, format='%Y-%m-%d %H:%M:%S')
update_time = serializers.DateTimeField(read_only=True, format='%Y-%m-%d %H:%M:%S')
class Meta:
model = ListModel
exclude = ['openid', 'is_delete', ]
read_only_fields = ['id', ]
class CustomerPostSerializer(serializers.ModelSerializer):
openid = serializers.CharField(read_only=False, required=False, validators=[datasolve.openid_validate])
customer_name = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
customer_city = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
customer_address = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
customer_contact = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
customer_manager = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
customer_level = serializers.IntegerField(read_only=False, required=True, validators=[datasolve.data_validate])
creater = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
class Meta:
model = ListModel
exclude = ['is_delete', ]
read_only_fields = ['id', 'create_time', 'update_time', ]
class CustomerUpdateSerializer(serializers.ModelSerializer):
customer_name = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
customer_city = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
customer_address = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
customer_contact = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
customer_manager = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
customer_level = serializers.IntegerField(read_only=False, required=True, validators=[datasolve.data_validate])
creater = serializers.CharField(read_only=False, required=True, validators=[datasolve.data_validate])
class Meta:
model = ListModel
exclude = ['openid', 'is_delete', ]
read_only_fields = ['id', 'create_time', 'update_time', ]
class CustomerPartialUpdateSerializer(serializers.ModelSerializer):
customer_name = serializers.CharField(read_only=False, required=False, validators=[datasolve.data_validate])
customer_city = serializers.CharField(read_only=False, required=False, validators=[datasolve.data_validate])
customer_address = serializers.CharField(read_only=False, required=False, validators=[datasolve.data_validate])
customer_contact = serializers.CharField(read_only=False, required=False, validators=[datasolve.data_validate])
customer_manager = serializers.CharField(read_only=False, required=False, validators=[datasolve.data_validate])
customer_level = serializers.IntegerField(read_only=False, required=False, validators=[datasolve.data_validate])
creater = serializers.CharField(read_only=False, required=False, validators=[datasolve.data_validate])
class Meta:
model = ListModel
exclude = ['openid', 'is_delete', ]
read_only_fields = ['id', 'create_time', 'update_time', ]
class FileRenderSerializer(serializers.ModelSerializer):
customer_name = serializers.CharField(read_only=False, required=False)
customer_city = serializers.CharField(read_only=False, required=False)
customer_address = serializers.CharField(read_only=False, required=False)
customer_contact = serializers.CharField(read_only=False, required=False)
customer_manager = serializers.CharField(read_only=False, required=False)
customer_level = serializers.IntegerField(read_only=False, required=False)
creater = serializers.CharField(read_only=False, required=False)
create_time = serializers.DateTimeField(read_only=True, format='%Y-%m-%d %H:%M:%S')
update_time = serializers.DateTimeField(read_only=True, format='%Y-%m-%d %H:%M:%S')
class Meta:
model = ListModel
ref_name = 'CustomereFileRenderSerializer'
exclude = ['openid', 'is_delete', ]
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Singosgu/GreaterWMS.git
git@gitee.com:Singosgu/GreaterWMS.git
Singosgu
GreaterWMS
GreaterWMS
master

搜索帮助