Ticket #8001: 8001_redirection_backward_compatibility.diff

File 8001_redirection_backward_compatibility.diff, 2.0 KB (added by Dario Ocles, 14 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 787f856..fbdadbb 100644
    a b from django.contrib import messages  
    1010from django.views.decorators.csrf import csrf_protect
    1111from django.core.exceptions import PermissionDenied, ValidationError
    1212from django.core.paginator import Paginator
     13from django.core.urlresolvers import reverse
    1314from django.db import models, transaction, router
    1415from django.db.models.related import RelatedObject
    1516from django.db.models.fields import BLANK_CHOICE_DASH, FieldDoesNotExist
    class ModelAdmin(BaseModelAdmin):  
    716717            "admin/change_form.html"
    717718        ], context, current_app=self.admin_site.name)
    718719
    719     def response_add(self, request, obj, post_url_continue='../%s/'):
     720    def response_add(self, request, obj, post_url_continue=None):
    720721        """
    721722        Determines the HttpResponse for the add_view stage.
    722723        """
    class ModelAdmin(BaseModelAdmin):  
    728729        # the presence of keys in request.POST.
    729730        if "_continue" in request.POST:
    730731            self.message_user(request, msg + ' ' + _("You may edit it again below."))
     732            if post_url_continue is None:
     733                post_url_continue = reverse("admin:%s_%s_change" % (opts.app_label, opts.module_name), args=(pk_value,), current_app=self.admin_site.name)
     734            else:
     735                try:
     736                    post_url_continue = post_url_continue % pk_value
     737                except TypeError:
     738                    pass
     739
    731740            if "_popup" in request.POST:
    732741                post_url_continue += "?_popup=1"
    733             return HttpResponseRedirect(post_url_continue % pk_value)
     742            return HttpResponseRedirect(post_url_continue)
    734743
    735744        if "_popup" in request.POST:
    736745            return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' % \
Back to Top