Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

[1.5.x] Fixed #20270 -- Fixed error in AjaxResponseMixin documentation

Backport of 73c26f0 from master.
  • Loading branch information...
commit 6bb8df0a982bb394f2cf33cfc9d9d71589515801 1 parent 4376a64
@bmispelon bmispelon authored claudep committed
Showing with 8 additions and 3 deletions.
  1. +8 −3 docs/topics/class-based-views/generic-editing.txt
11 docs/topics/class-based-views/generic-editing.txt
@@ -237,19 +237,24 @@ works for AJAX requests as well as 'normal' form POSTs::
return HttpResponse(data, **response_kwargs)
def form_invalid(self, form):
+ response = super(AjaxableResponseMixin, self).form_invalid(form)
if self.request.is_ajax():
return self.render_to_json_response(form.errors, status=400)
- return super(AjaxableResponseMixin, self).form_invalid(form)
+ return response
def form_valid(self, form):
+ # We make sure to call the parent's form_valid() method because
+ # it might do some processing (in the case of CreateView, it will
+ # call for example).
+ response = super(AjaxableResponseMixin, self).form_valid(form)
if self.request.is_ajax():
data = {
- 'pk':,
+ 'pk':,
return self.render_to_json_response(data)
- return super(AjaxableResponseMixin, self).form_valid(form)
+ return response
class AuthorCreate(AjaxableResponseMixin, CreateView):
model = Author
Please sign in to comment.
Something went wrong with that request. Please try again.