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

前端 未结 1 1313
一个人的身影
一个人的身影 2021-02-06 10:32

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

1条回答
  •  一生所求
    2021-02-06 11:00

    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.

    0 讨论(0)
提交回复
热议问题