这是我的模板路径
project/templates/app_name/delete_confirmation.html
{% extends "admin/base_site.html" %}
{% load i18n admin_urls %}
{% block content %}
{% if perms_lacking %}
<p>{% blocktrans with escaped_object=object %}Deleting the {{ object_name }} '{{ escaped_object }}' would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktrans %}</p>
<ul>
{% for obj in perms_lacking %}
<li>{{ obj }}</li>
{% endfor %}
</ul>
{% elif protected %}
<p>{% blocktrans with escaped_object=object %}Deleting the {{ object_name }} '{{ escaped_object }}' would require deleting the following protected related objects:{% endblocktrans %}</p>
<ul>
{% for obj in protected %}
<li>{{ obj }}</li>
{% endfor %}
</ul>
{% else %}
<p>{% blocktrans with escaped_object=object %}Are you sure you want to delete the {{ object_name }} "{{ escaped_object }}"? All of the following related items will be deleted:{% endblocktrans %}</p>
{% include "admin/includes/object_delete_summary.html" %}
<h2>{% trans "Objects" %}</h2>
<ul>{{ deleted_objects|unordered_list }}</ul>
<form action="" method="post">{% csrf_token %}
<div>
<input type="hidden" name="post" value="yes" />
{% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1" />{% endif %}
{% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}" />{% endif %}
<input type="submit" value="{% trans "Yes, I'm sure" %}" />
<a href="#" onclick="window.history.back(); return false;" class="button cancel-link">{% trans "No, take me back" %}</a>
</div>
</form>
<input type="submit" value="{% trans "Cancel" %}" onclick="window.history.back(); return false;"/>
{% endif %}
{% endblock %}
我正在尝试继承django-admin的delete_confirmation.html
模板。我想在删除应用中的对象时添加cancel
按钮。它显示了取消按钮,它也可以正常工作,但delete
按钮不执行任何操作。
我试图在“本地模板”中添加链接,这些链接在“管理模板”中定义,但它引发了“反向网址未找到”的错误。有没有办法解决这个问题?请建议我正确的方法。
先谢谢。
答案 0 :(得分:1)
不是继承django-admin的delete-confirmation.html模板,而是将模板从 django / contrib / admin / templates / admin / delete_confirmation.html 复制到项目目录中,然后自行进行更改。