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".
我想使用django contrib.admin页面来编辑我的模型,但是从我自己的视图中调用单个更改页面,然后在用户单击“保存”后返回该页面。
Ideally this should happen by appending the return URL to the admin page's url (as in "...?_return_url=)
理想情况下,这应该通过将返回URL附加到管理页面的URL来实现(如“......?_ return_url =”)
Any hints?
1 个解决方案
#1
13
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.
django.contrib.admin.options.ModelAdmin对象有一个response_change方法,您可以在子类中覆盖该方法以确定在成功保存对象后应返回的响应 - 您可以覆盖此方法以返回对象的相应HttpResponseRedirect。刚刚被救了。
#1
13
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.
django.contrib.admin.options.ModelAdmin对象有一个response_change方法,您可以在子类中覆盖该方法以确定在成功保存对象后应返回的响应 - 您可以覆盖此方法以返回对象的相应HttpResponseRedirect。刚刚被救了。