class Meta:
     # 模型
     model = Client
     # 序列化字段
     fields = '__all__'
     # 级联层级
     depth = 0
     # 只读字段
     read_only_fields = ('create_time', 'update_time', 'is_delete',  # 公共字段
                         'secret_key', 'pushed_num')
     # 而外参数
     extra_kwargs = SerializerUtil.get_extra_kwargs(model=model, read_only_fields=read_only_fields,
                                                    validators={'name': [UniqueValidator(queryset=Client.objects.all(),
                                                                                         message='客户已被注册')]})
 class Meta:
     # 模型
     model = Report
     # 序列化字段
     fields = '__all__'
     # 级联层级
     depth = 0
     # 只读字段
     # read_only_fields = ('create_time', 'update_time', 'is_delete',  # 公共字段
     #                     )
     read_only_fields = tuple(utils.get_model_fields(model,
                                                     exclude_list=[]))
     # 而外参数
     extra_kwargs = SerializerUtil.get_extra_kwargs(
         model=model, read_only_fields=read_only_fields)
示例#3
0
 class Meta:
     # 模型
     model = RechargeRecord
     # 序列化字段
     fields = '__all__'
     # 级联层级
     depth = 0
     # 只读字段
     read_only_fields = (
         'create_time',
         'update_time',
         'is_delete',  # 公共字段
     )
     # 而外参数
     extra_kwargs = SerializerUtil.get_extra_kwargs(
         model=model, read_only_fields=read_only_fields)
示例#4
0
 class Meta:
     # 模型
     model = PushRecord
     # 序列化字段
     fields = '__all__'
     # 级联层级
     depth = 0
     # 只读字段
     read_only_fields = (
         'create_time',
         'update_time',
         'is_delete',  # 公共字段
         'result',
         'response_message',
         'client')
     # 而外参数
     extra_kwargs = SerializerUtil.get_extra_kwargs(
         model=model, read_only_fields=read_only_fields)
 class Meta:
     # 模型
     model = User
     # 序列化字段
     fields = '__all__'
     # 级联层级
     depth = 0
     # 只读字段
     read_only_fields = ('create_time', 'update_time', 'is_delete',  # 公共字段
                         'last_login', 'is_superuser', 'first_name', 'last_name', 'date_joined', 'groups',
                         'user_permissions', 'is_staff', 'is_active')
     # 而外参数
     extra_kwargs = SerializerUtil.get_extra_kwargs(model=model, read_only_fields=read_only_fields,
                                                    write_only_fields=('password'),
                                                    validators={
                                                        'username': [UniqueValidator(queryset=User.objects.all(),
                                                                                 message='用户名已经存在')]
                                                    },
                                                    style={
                                                        'password': {'input_type': 'password'}
                                                    }
                                                    )