已models.py的CharField字段代码为起点
secret_id = models.CharField("secret_id", max_length=256, default="")
构造方法中,会去调父类Field
的构造方法,而后向
CharField
的验证器列表
中添加一个
MaxLengthValidator
对象,用于验证该字段的值是否超过了最大
长度限制。
![](https://img-blog.csdnimg.cn/51197e77898546ad898c00b8f59ced25.png)
调到Field的构造方法:
CharField方法中
check
和
_check_max_length_attribute
方法,检查 C