X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/cf21ebb1502a1f5b7dfc285b9f9e3af4ede3e993..80d789aa009be1449b83b04b5838ebcc15368d68:/apps/ajaxable/utils.py diff --git a/apps/ajaxable/utils.py b/apps/ajaxable/utils.py index 52cf63833..4ae6e869e 100755 --- a/apps/ajaxable/utils.py +++ b/apps/ajaxable/utils.py @@ -101,14 +101,16 @@ class AjaxableFormView(object): form = self.form_class(*form_args, **form_kwargs) if form.is_valid(): add_args = self.success(form, request) - redirect = request.GET.get('next') - if not request.is_ajax() and redirect: - return HttpResponseRedirect(urlquote_plus( - redirect, safe='/?=&')) - response_data = {'success': True, - 'message': self.success_message, 'redirect': redirect} + response_data = { + 'success': True, + 'message': self.success_message, + 'redirect': request.GET.get('next') + } if add_args: response_data.update(add_args) + if not request.is_ajax() and response_data['redirect']: + return HttpResponseRedirect(urlquote_plus( + response_data['redirect'], safe='/?=&')) elif request.is_ajax(): # Form was sent with errors. Send them back. if self.form_prefix: