Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Fixed #19044 -- Allow get_success_url to access self.object in DeletionMixin #417

wants to merge 1 commit into from

4 participants


generic_views tests passes


I don't think the get_success_url method needs to change - it seems a pretty odd change to me anyway. The change to delete looks good though and makes sense.


Please take a look at
Change to get_success_url is necessary for example to redirect to object parent after its deletion


IMHO you shouldn't refer to an URL this way, you should use the reverse_lazy function here.

I have to agree with @mjtamlyn about the changes of the get_success_url method. You just can't assume that the specified success_url should be formatted using the instance's __dict__.


Why get_success_url of DeletionMixin cannot format url in the same way as get_success_url of ModelFormMixin in the same file?


Sorry, didn't realise it was a consistency thing. In that case the change should be there for consistency purposes, although I still think the feature smells ;)


@0x0badc0de please forgive me, didn't notice that. I wonder if it's documented somewhere.


Needs tests as noted on the ticket.


#663 has tests.

@charettes charettes closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 django/views/generic/
5 django/views/generic/
@@ -240,8 +240,9 @@ def delete(self, request, *args, **kwargs):
redirects to the success URL.
self.object = self.get_object()
+ success_url = self.get_success_url()
- return HttpResponseRedirect(self.get_success_url())
+ return HttpResponseRedirect(success_url)
# Add support for browsers which only accept GET and POST for now.
def post(self, *args, **kwargs):
@@ -249,7 +250,7 @@ def post(self, *args, **kwargs):
def get_success_url(self):
if self.success_url:
- return self.success_url
+ return self.success_url % self.object.__dict__
raise ImproperlyConfigured(
"No URL to redirect to. Provide a success_url.")
Something went wrong with that request. Please try again.