I have a problem with a form submission :
My script JS :
function submit_form(){
var form = $("#theform").serializeArray();
var the_players = document.getElementsByName("theplayers");
var tab_players = [];
for(variable of the_players){
var name = variable.id.split("_")[1];
tab_players.push(variable.value);
}
// *** I send a tab and THE FORM ***
$.post("/myview_players",{"theplayers[]": tab_players,"form[]":form}).done(function(data){window.location.reload();});
return false;
}
And the view (url : 'myview_players') :
...
if request.method == "POST":
requete = request.POST
if requete.is_ajax() :
form = playersForm(requete.get("form"))
if form.is_valid() :
print("Valid ! ")
else :
print("Not valid...")
...
I pass in argument to the playersForm juste a form sent by Ajax. In the terminal, the message "Not valid" is showed... Why ?