赞
踩
| 字段 | 描述 |
|---|---|
| IntegerField | 整型 |
| CharField | 字符型 |
| FloatField | 浮点型 |
| BooleanField | 布尔型 |
| EmailField | 邮箱类型 |
| DecimalField | 保留小数点型 |
| ImageField | 图片型 |
| FileField | 文件型 |
| ChoiceField | 多重选择型 |
| DateField | 日期型 |
| TimeField | 时间型 |
| DateTimeField | 日期时间型 |
| PrimaryKeyRelatedField | 外键关联型 |
| 参数名称 | 说明 |
|---|---|
| max_length | 字符串最大长度 |
| min_length | 字符串最小长度 |
| max_value | 数字最大值 |
| min_value | 数字最小值 |
| read_only | 默认False,若设置为True,表明对应字段只在序列化操作中起作用 |
| write_only | 默认作用False,若设置为True,表明对应字段只在反序列化操作中起作用 |
| required | 默认True,表明对应字段在反序列化操作进行数据校验时必须传入 |
| defalut | 字段设置的默认值,设置的同时,required值自动变为False |
| label | 字段的描述 |
| error_messages | 字典类型,自定义错误描述,可针对长度、大小、是否必填来设置,如{“required”:“XXX字段不能为空”} |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。