1

这个问题之前被问过几次,但我没有得到合适的答案。

  1. 在 django 管理仪表板中,我想删除更改按钮。
  2. 删除更改按钮后,添加按钮应向左对齐。
  3. has_change_permission通过在方法中设置 false 来移除更改按钮时,不应禁用模型名称上的超链接。
  4. 单击超链接时,应该只能查看内容。不应允许任何人更改内容。

这可能吗?

4

1 回答 1

0

Indeed it can be done. One would have to override the main admin index.html template, and in there make all custom changes they wish.

For example:

{% if model.perms.change %}
     <td><a href="{{ model.admin_url }}" class="changelink">{% trans 'Change' %}</a></td>
{% else %}
    <td>&nbsp;</td>
{% endif %}

could be changed with just:

<td>&nbsp;</td>

as far as "Add" going to left one would have to redesign the table (it depends on haw far exactly link would have to be. Also all of other points in question could be redone in this fashion.

My emphasis at this point would be to encourage not to override directly in the site packages, but instead override it with the creating index.html in global templates/admin folder. Even this has to be considered and done if absolutely necessary.

于 2013-02-20T14:24:49.967 回答