background:
A web system developed using flask. The background user management adopts load mode without refreshing dynamic loading
1, as shown in the picture, click "Yanzhou Mining Group", and dynamically load the page on the right
html:usermanage.html,:
:
:usermanage_ajax.html:
:
2
adduserformwtform
:
adduser:
usermanage_ajax.htmlajaxpostadduser:
:
I probably understand that it is because of the request made from system/usermanage, and referer points to system/usermanage, so I return here, but because I did not set the POST method for the view function of system/usermanage, I reported this error. What I want to ask is how to handle this? So that he can achieve the effect I need (showing the notice.html view, that is, a similar effect)
3. The method I have tried
if you write url to the action of form instead of using ajax post, in usermanage_ajax.html, the program will not report an error when executed at this place, but it does not seem to display a verification error message on the current page without using ajax
try:
general.SQL(sql)
info["type"] = "success"
info["title"] = ""
info["notice"] = "" + username + " "
print("")
return render_template("notice.html", info=info) -sharp
except Exception as error:
print(request.path, error)
info["type"] = "warning"
info["title"] = ""
info["notice"] = ""
return render_template("notice.html", info=info)
4. Please help me. I have been stuck with this question for 3 days. Thank you very much. Half-way monk programmer, level comparison
summary, do not let him have 405 errors, can normally return to my notice view
5, P.S. Another question is why wtforms validation can still be submitted even if there is an error. Shouldn"t we stop and wait for correction input?
if it is empty, the page will not be submitted, but for example, the mailbox is filled in, but the format is incorrect, or the number of digits on the phone is incorrect (I have crawled the error at the backend), but why is the page still submitted? (then the 405 error is displayed)