Django

Code

Ticket #3128 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] add an object_tools block to admin templates

Reported by: Gary Wilson <gary.wilson@gmail.com> Assigned to: adrian
Milestone: Component: django.contrib.admin
Version: SVN Keywords:
Cc: gary.wilson@gmail.com Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Currently, if I want to add object tools I have you have to override all of block content:

{% block content %}
<div id="content-main">
<ul class="object-tools">
{% if has_add_permission %}
    <li><a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans %}</a></li>
    <li><a href="myaction">Myaction</a></li>
{% endif %}
</ul>
<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
{% block search %}{% search_form cl %}{% endblock %}
{% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
{% block filters %}{% filters cl %}{% endblock %}
{% block result_list %}{% result_list cl %}{% endblock %}
{% block pagination %}{% pagination cl %}{% endblock %}
</div>
</div>
{% endblock %}

With a {% block object_tools %}, it could just be:

{% block object_tools %}
<ul class="object-tools">
{% if has_add_permission %}
    <li><a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans %}</a></li>
    <li><a href="myaction">Myaction</a></li>
{% endif %}
</ul>
{% endblock %}

The object tools area seems to be one of the only places that doesn't already have a block.

Attachments

change_list.diff (0.8 kB) - added by Gary Wilson <gary.wilson@gmail.com> on 12/11/06 14:06:08.
object-tools-block.diff (2.5 kB) - added by Gary Wilson <gary.wilson@gmail.com> on 12/19/06 22:35:45.
block in admin/base.html with overrides in change_list and change_form

Change History

12/11/06 14:06:08 changed by Gary Wilson <gary.wilson@gmail.com>

  • attachment change_list.diff added.

12/19/06 11:12:49 changed by Gary Wilson <gary.wilson@gmail.com>

12/19/06 22:33:13 changed by anonymous

  • summary changed from [patch] add an object_tools block to change_list.html template to [patch] add an object_tools block to admin templates.

not just change_list.html

12/19/06 22:35:45 changed by Gary Wilson <gary.wilson@gmail.com>

  • attachment object-tools-block.diff added.

block in admin/base.html with overrides in change_list and change_form

12/19/06 22:36:11 changed by Gary Wilson <gary.wilson@gmail.com>

  • cc set to gary.wilson@gmail.com.

12/19/06 23:00:37 changed by jacob

  • status changed from new to closed.
  • resolution set to fixed.

(In [4230]) Fixed #3128: Added explicit object-tools block so custom admin templates can override it where needed. Thanks, Gary Wilson.


Add/Change #3128 ([patch] add an object_tools block to admin templates)




Change Properties
Action