Django forms: cannot call form.clean
考虑以下堆栈跟踪:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
In [3]: f.clean() ————————————————————————— AttributeError Traceback (most recent call last) C://Users//Marcin//Documents//oneclickcos//lib//site-packages//django//core//management//commands//shell.pyc in <module>() —-> 1 f.clean() C://Users//Marcin//Documents//oneclickcos//oneclickcos//mainapp//incorporate_helpers.pyc in clean(self) 573 try: C://Users//Marcin//Documents//oneclickcos//oneclickcos//mainapp//incorporate_helpers.pyc in clean(self) 406 if cleaned_data.get(‘pk’, None) == ”: del cleaned_data[‘pk’] C://Users//Marcin//Documents//oneclickcos//lib//site-packages//django//forms//forms.pyc in clean(self) AttributeError: ‘IncorporateForm’ object has no attribute ‘cleaned_data’ |
(所有相关代码都显示在上面的跟踪中)。
我的代码符合 https://docs.djangoproject.com/en/1.4/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other 中的示例;但是,似乎 BaseForm 返回期望
我在文档中没有看到在调用
django 1.4 和 1.3.1 出现错误。
您根本不应该直接调用
据我所知,文档从不建议您直接调用
在底层,调用
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/python/267905.html