开发者

Accessing the object in a django admin template

开发者 https://www.devze.com 2023-02-03 09:39 出处:网络
I\'m overriding the change_form.html template and want to display links to other related objects. When overriding an admin template, is there a way to access the object that is beeing edited in the

I'm overriding the change_form.html template and want to display links to other related objects.

When overriding an admin template, is there a way to access the object that is beeing edited in the template? Or perhaps pass that object to the template when r开发者_JS百科egistering it to the admin in some way?


A quick look at django.contib.admin.options' change_view method shows the original object is included as a context variable called original. So if you're simply overriding change_form.html itself you can get to the object being edited via {{ original }}.

0

精彩评论

暂无评论...
验证码 换一张
取 消