{% load add_preserved_filters from admin_urls %}

{% if tool.button_type == 'a' %}
  <a href="{% add_preserved_filters action_url %}"
    title="{{ tool.standard_attrs.title }}"
    {% for k, v in tool.custom_attrs.items %}
      {{ k }}="{{ v }}"
    {% endfor %}
    class="{{ tool.standard_attrs.class }}"
  >{{ tool.label|capfirst }}</a>
{% elif tool.button_type == 'form' %}
  <form method="post" action="{% add_preserved_filters action_url %}">
    {% csrf_token %}
    <a href="#" onclick="this.parentNode.submit(); return false;"
      title="{{ tool.standard_attrs.title }}"
      {% for k, v in tool.custom_attrs.items %}
        {{ k }}="{{ v }}"
      {% endfor %}
      class="{{ tool.standard_attrs.class }}"
    >{{ tool.label|capfirst }}</a>
  </form>
{% endif %}
