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
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
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.
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
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