diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 4d23f8f..5e78bce 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -776,14 +776,17 @@ class ModelAdmin(BaseModelAdmin): self.message_user(request, msg + ' ' + _("You may edit it again below.")) if "_popup" in request.POST: post_url_continue += "?_popup=1" + if '_callback' in request.REQUEST: + post_url_continue += '&_callback=%s' % request.REQUEST.get('_callback') return HttpResponseRedirect(post_url_continue % pk_value) if "_popup" in request.POST: + popup_callback = request.REQUEST.get('_callback', 'dismissAddAnotherPopup') return HttpResponse( '' - '' % \ + '' % \ # escape() calls force_unicode. - (escape(pk_value), escapejs(obj))) + (popup_callback, escape(pk_value), escapejs(obj))) elif "_addanother" in request.POST: self.message_user(request, msg + ' ' + (_("You may add another %s below.") % force_unicode(opts.verbose_name))) return HttpResponseRedirect(request.path) @@ -1004,6 +1007,8 @@ class ModelAdmin(BaseModelAdmin): 'errors': helpers.AdminErrorList(form, formsets), 'app_label': opts.app_label, } + if '_callback' in request.REQUEST: + context.update({'popup_callback': request.REQUEST.get('_callback')}) context.update(extra_context or {}) return self.render_change_form(request, context, form_url=form_url, add=True) @@ -1234,6 +1239,7 @@ class ModelAdmin(BaseModelAdmin): 'selection_note_all': selection_note_all % {'total_count': cl.result_count}, 'title': cl.title, 'is_popup': cl.is_popup, + 'popup_callback': cl.popup_callback, 'cl': cl, 'media': media, 'has_add_permission': self.has_add_permission(request), diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html index 82d7296..937f0c1 100644 --- a/django/contrib/admin/templates/admin/change_form.html +++ b/django/contrib/admin/templates/admin/change_form.html @@ -37,7 +37,7 @@ {% endblock %}
{% csrf_token %}{% block form_top %}{% endblock %}
-{% if is_popup %}{% endif %} +{% if is_popup %}{% if popup_callback %}{% endif %}{% endif %} {% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %} {% if errors %}

diff --git a/django/contrib/admin/templates/admin/change_list.html b/django/contrib/admin/templates/admin/change_list.html index c72b663..c6b82ca 100644 --- a/django/contrib/admin/templates/admin/change_list.html +++ b/django/contrib/admin/templates/admin/change_list.html @@ -54,7 +54,7 @@