

Django Form Invalid, Despite No Errors
以下为 快照 页面,建议前往来源网站查看,会有更好的阅读体验。
原文链接: https://snakeycode.wordpress.com/2019/07/08/django-form-invalid-despite-no-errors/
Standard
Django Form Invalid, Despite No Errors
I was using Django CBV FormView. The form was being flagged as invalid but when I inspected the form inside the form_invalid() method using the PyCharm debugger, there were no errors. When I traced deeper into the Django code, I found this line that is returned by the is_valid() method.:
return
self
.is_bound
and
not
self
.errors
It turned out my form was not bound. But why would that be???
The problem was I over-rode the get_form_kwargs() method and forgot to call super(). The POST data is one of the kwargs passed to the form. If you don’t call super(), the post data does not make it into the form kwargs. Hence the form remains unbound.
猜你喜欢
-
2
Remove django form field validation errors manuallyRemove django form field validation errors manually Tue 06 December 2011Original post at Makina Corpus Sometimes I look fo...
-
2
Standard Django: Passing Form Values in URL Lets say you have a form that is used to drive the next page. For example, it might contain parameters for running a report. One way to ha...
-
5
Standard Django: Putting Form Values in the URL Query String I used to avoid using URLs with long query strings. This was partially due to an essay I read by a Big Shot about how URL...
-
54
-
72
A short integer 's' is defined as: 'short s = 0;'. Which one of given increment expressions is invalid or will fail to compile?
-
35
事实起因 最近在ORM上使用了ibatis,感觉挺繁琐的,没有jpa来的直接,但项目非要用也没有办法,最近在进行开发过程中出现了一个问题 Invalid bound statement (not found) 意思是说,你的xml映射和你的mapper...
-
54
Google’s John Mueller recently provided some guidance with regards to invalid URLs on a website. An invalid URL should return a 404 error so it’s clear to Google that the URL does not belong to a particular site....
-
98
原文地址: golang报错:net/http: invalid header field value "Basic 昨天被这个问题困扰了一天,今天终于找到问题了。 先说一下我这里的流程: 1....
-
39
4 次查看 出现Invalid Host header解决办法 内网穿透 适用场景: 在本地的Vue-cli3项目, 需要其他人浏览. 如果没有外网的服务器, 可以把自己的电脑当做服务器. 这时候需要外网的人能访问到自己...
-
10
Emacs as a Shell 30 April 2020 When I log into a new server, one of the first things I do is install a minimal Emacs package
关于极客头条
聚合每日国内外有价值,有趣的链接。