def form_invalid(self, form, prefix=None):
        """ If form invalid return error list in JSON response """
        response = super(FormAjaxMixin, self).form_invalid(form)
        if self.request.is_ajax():
            data = {
                "errors_list": self.add_prefix(form.errors, prefix),
            }
            return self.json_to_response(status=400, json_data=data,
                                         json_status=AjaxResponseStatus.ERROR)
        return response
def form_invalid ( self , form , prefix = None ) : response = super ( FormAjaxMixin , self ) . form_invalid ( form ) if self . request . is_ajax ( ) : data = { "errors_list" : self . add_prefix ( form . errors , prefix ) , } return self . json_to_response ( status = 400 , json_data = data , json_status = AjaxResponseStatus . ERROR ) return response
If form invalid return error list in JSON response