摘要: 一、验证顺序 查看form下的源码了解顺序 BaseForm为基类,中间包含了is_valid校验方法 @html_safe class BaseForm: #......... def __init__(): self.is_bound = data is not None or files is 阅读全文
posted @ 2020-05-31 16:42 JIMfan 阅读(404) 评论(0) 推荐(0) 编辑
摘要: 先来归纳一下整个流程首先is_valid()起手,看seld.errors中是否值,只要有值就是flase接着分析errors.里面判断_errors是都为空,如果为空返回self.full_clean(),否则返回self._errors现在就要看full_clean(),是何方神圣了,里面设置_ 阅读全文
posted @ 2020-05-31 16:05 JIMfan 阅读(156) 评论(0) 推荐(0) 编辑
摘要: Python - 查看类的方法和属性,dir(),help() 1. dir()查看类的方法和属性 dir([object]) 2.help()查看函数或模块用途的详细说明 help([object]) 3.查看具体类中某方法的详细说明 help(object.method_name) 例如:查看s 阅读全文
posted @ 2020-05-31 15:42 JIMfan 阅读(9784) 评论(0) 推荐(0) 编辑
摘要: form验证预留了3个可自定制数据验证的三个方法 self._clean_字段名() #针对单个字段预留的方法(也就是该字段通过form验证以后就会触发该对应名字的自定义方法) self._clean_form() #针对多个字段预留的方法 self._post_clean() #针对多个字段预留的 阅读全文
posted @ 2020-05-31 12:27 JIMfan 阅读(668) 评论(0) 推荐(0) 编辑