程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

When submitting the Django form component, the error is not displayed or cannot be submitted

編輯:Python

What happened : I'm learning django Of form When the component , Yes, it doesn't conform to form Component defined fields cannot be submitted , As a result, customized error messages cannot be displayed .( Because failure to submit means that the data has not been transferred to the background , Then your error echo is returned to the front end after the data is found to be inconsistent in the background inspection ) This is obviously an unreasonable design for users , Not allowed to submit without telling me what went wrong .

Cause of error : In direct use form When components are rendered , If you set a required field ( Default is also required ), Well, the... Of this field input The label will have required This attribute , If not , When the front end finds that the value is empty, it is not allowed to submit , So we just need to form Add attribute value to the tag novalidate, It means that the input field is not checked .

resolvent : stay form Add... After the label novalidate, No input validation for this form .

summary : In the past, when writing front-end forms, you always wrote a type and name , No other properties have been used at all , So this time, I also suffered the loss of not understanding the front end . Thanks to the documents I read for a long time , Look at the source code earlier , Look at what he is rendering. It may have been solved long ago .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved