I am working with Django and Ajax. With the help of jQuery, i successfully sent form data to server and able to validate it.
Problem arrive when form is invalid, i want that, if the form is invalid, ajax get the invalid form and render it to same template with errors like all invalid forms do.
How Can i do it ?
The closest method you can do is to return Form.errors. For example:
The
response_data['errors']will contain a dictionary of error messages like:After sending the ajax request, you can use jQuery to display the errors on the form elements. Note that you will have to find a way to append the error messages next to their elements.