Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I customize django admin change pages to return to a specific URL on "save"

Tags:

django

I would like to use the django contrib.admin pages to edit my models, but call individual change page from my own views, an then return there after user clicks "save".

Ideally this should happen by appending the return URL to the admin page's url (as in "...?_return_url=)

Any hints?

like image 773
Ber Avatar asked Oct 27 '08 17:10

Ber


1 Answers

django.contrib.admin.options.ModelAdmin objects have a response_change method which you can override in a subclass to determine the response which should be returned after an object has been successfully saved - you could override this to return an appropriate HttpResponseRedirect for the object which was just saved.

like image 128
Jonny Buchanan Avatar answered Nov 15 '22 07:11

Jonny Buchanan