views:

216

answers:

3

Hello,

How can i redirect user to different app on save ?

I have two app say app1 and app2.If user click on save in app2 then it should be redirected to app1 rather then the default page

I want in admin not in customform

+1  A: 

To change the redirect destination after save in the admin, you need to override response_add() (for adding new instances) and response_change() (for changing existing ones) in the ModelAdmin class.

See the original code in django.contrib.admin.options.

And if you want people to keep helping you on StackOverflow, you need to accept answers to your questions.

Daniel Roseman
i havent said that i am not accepting the answer.It was typing mistake and i have corrected it.
ha22109
can u explain it little more .I am not able to find it out
ha22109
What does a typing error have to do with it? You have asked 35 questions on StackOverflow, and you haven't accepted a best answer for a single one. That is very bad manners.
Daniel Roseman
i am not aware of this that we have to accept answer manually.
ha22109
http://meta.stackoverflow.com/questions/5234/accepting-answers-what-is-it-all-about
alex vasi
A: 

Maybe take a look at URL namespaces... You could probably use HttpResponseRedirect + reverse to redirect the user inside of your overridden save method. Keep in mind that this is a new feature in Django 1.1 and is not supported in 1.0.x.

http://docs.djangoproject.com/en/dev/topics/http/urls/#url-namespaces

Jon Mooring
A: 

def change_view(self, request, object_id,extra_context=None):

result = super(mymodeladmin, self).change_view(request, object_id, extra_context)

result['Location'] = "your location"

return result
ha22109