python - 扩展 django 管理模板

标签 python django django-admin django-1.10

我正在尝试在页面顶部的添加对象旁边的change_list django管理页面中添加一个自定义按钮。

{% extends "admin/change_list.html" %} 
{% load i18n %} 
{% block object-tools-items %}
{{ block.super }}
<li>
    <button class="" href="...">Click Here!</button>
</li>
{% endblock %}

我遵循了很多教程,但没有成功。 我的 settings.py 中有 'APP_DIRS': True, ,我的项目如下:

project/
    app/
        templates/
            change_list.html
            custom_template.html

custom_template.html 是change_list 中的一个操作,并且它可以工作。 我错过了什么吗?

编辑:

已经尝试过:

project/app/templates/admin/change_list.html project/app/templates/app/admin/change_list.html

也没用。

最佳答案

change_list.html 覆盖文件位于此位置:

project/app/templates/admin/app/change_list.html

你快明白了。 :)

您也可以使用 django-debug-toolbar 并获取在浏览器端上传的实际模板。

关于python - 扩展 django 管理模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40819190/

相关文章:

python - 线程 Flask 应用程序未按预期工作

python - << : 'str' and 'int' while reading file 不支持的操作数类型

jquery - ajax 请求在 django 中不起作用?

mysql - 使用 Django dumpdata 转储整体数据的一个子集?

Django 管理日志条目 : how it works in non admin actions?

Django 管理员登录不重定向

python - 需要 'package' 参数来执行相对导入

python - 使用 sqlalchemy 在 sqlite 数据库中存储列表/元组

javascript - HTML 5 下载属性在 Safari 浏览器中不起作用

django - 如何在 Django 中设置基本 URL