tags:

views:

752

answers:

2

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?

+4  A: 

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.

insin
This is an excellent hint. It also needs overriding of the change_view method and some costomized templates to get the target URL into the change view's page.Its a good thing this requires no change inside the admin code, just overrides in derived classes and templates.
Ber
Thanks alot for this, was really stuck until i read your answer!
Mark Ellul
+1  A: 

I found this blog post helped me understand insin's answer:

http://joshourisman.com/2008/10/27/modifying-django-admin-redirects-after-adding-changing-and-deleting/

adonm