Answer the question
In order to leave comments, you need to log in
How to properly serialize in Django or process in JS?
Good day.
I'm trying to serialize form.error.items() into a view and process this js:
if user_form.is_valid():
\\....
else:
data = dict([(k, [e for e in v]) for k,v in user_form.errors.items()])
return JsonResponse(data)
success : function(json) {
if (json.redirect){
window.location.href = json.redirect;
}
$('.form-control').val('');
var error = jQuery.parseJSON(data);
$("#error").html(error.username);
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question