在django admin

时间:2015-11-09 15:02:46

标签: python django django-admin django-reversion

我正在定制django管理员,所以我通过"扩展admin / change_list.html"为模型管理员添加了一个自定义按钮。模板

    {% block object-tools-items %}
      //add custom button here
    {% endblock %}

看起来像这样

enter image description here

当我为模型版本添加新包django-reversion时 它创建了用于恢复数据的新按钮,但重新创建了我创建的自定义按钮。我发现这种情况正在发生,因为package还扩展了admin / change_list.html模板并覆盖了object-tools-items块。

enter image description here

我想要这样的事情。请帮忙。

enter image description here

1 个答案:

答案 0 :(得分:0)

You were already told the answer when you raised this "bug" on the reversion Github

  

只需使用您自己的自定义扩展reversion / change_list.html模板即可   模板。 :)

而不是使用路径admin/change_list.html创建模板,而不是使用路径reversion/change_list.html创建覆盖模板。这样做的原因是,reversion会对自己的模板进行一些覆盖,因此你需要确保与这些模板完美搭配。