def form_invalid(self, form):
if self.request.is_ajax():<EOL><INDENT>return self.render_json_response(self.get_error_result(form))<EOL><DEDENT>return super(AjaxFormMixin, self).form_invalid(form)<EOL>
We have errors in the form. If ajax, return them as json.
Otherwise, proceed as normal.