{% extends 'generic/_base.html' %} {% load buttons %} {% load helpers %} {% load plugins %} {% load render_table from django_tables2 %} {% load static %} {% load i18n %} {% comment %} Blocks: - title: Page title - controls: Control elements displayed between the header and content - extra_controls: Any additional action buttons to display - tabs: Page tabs - content: Primary page content - bulk_buttons: Additional bulk action buttons to display beneath the objects list - modals: Any pre-loaded modals Context: - model: The model class being listed - table: The table class used for rendering the list of objects - actions: A list of buttons to display. This template checks for add, import, export, bulk_edit, and bulk_delete. - filter_form: The bound filterset form for filtering the objects list (optional) - return_url: Return URL to use for bulk actions (optional) {% endcomment %} {% block title %}{{ model|meta:"verbose_name_plural"|bettertitle }}{% endblock %} {% block controls %}
{% plugin_list_buttons model %} {% block extra_controls %}{% endblock %} {% if 'add' in actions %} {% add_button model %} {% endif %} {% if 'import' in actions %} {% import_button model %} {% endif %} {% if 'export' in actions %} {% export_button model %} {% endif %}
{% endblock controls %} {% block tabs %} {% endblock tabs %} {% block content %} {# Object list tab #}
{# Applied filters #} {% if filter_form %} {% applied_filters model filter_form request.GET %} {% endif %} {# Object table controls #} {% include 'inc/table_controls_htmx.html' with table_modal="ObjectTable_config" %}
{% csrf_token %} {# "Select all" form #} {% if table.paginator.num_pages > 1 %}
{% if 'bulk_edit' in actions %} {% bulk_edit_button model query_params=request.GET %} {% endif %} {% if 'bulk_delete' in actions %} {% bulk_delete_button model query_params=request.GET %} {% endif %}
{% endif %}
{% csrf_token %} {# Warn of any missing prerequisite objects #} {% if prerequisite_model %} {% include 'inc/missing_prerequisites.html' %} {% endif %} {# Objects table #}
{% include 'htmx/table.html' %}
{# /Objects table #} {# Form buttons #}
{% block bulk_buttons %} {% if 'bulk_edit' in actions %} {% bulk_edit_button model query_params=request.GET %} {% endif %} {% if 'bulk_delete' in actions %} {% bulk_delete_button model query_params=request.GET %} {% endif %} {% endblock %}
{# /Form buttons #}
{# /Object list tab #} {# Filters tab #} {% if filter_form %}
{% include 'inc/filter_list.html' %}
{% endif %} {# /Filters tab #} {% endblock content %} {% block modals %} {% table_config_form table table_name="ObjectTable" %} {% endblock modals %}