{% load crispy_forms_field %} {% comment %} Override of crispy-bootstrap5's field_file.html that supports PersistentFileWidget. When the widget context contains ``has_file`` (set by PersistentFileWidget.get_context), the persistent-file UI is rendered. Otherwise, the standard crispy file-input markup is used. {% endcomment %} {% for widget in field.subwidgets %} {% if widget.data.has_file %} {# --- PersistentFileWidget: uploaded file with Replace / Remove --- #} {% include "conjunto/forms/_persistent_file.html" with widget=widget.data %} {% include "bootstrap5/layout/help_text_and_errors.html" %} {% else %} {# --- Standard ClearableFileInput / FileInput --- #} {% if widget.data.is_initial %}
{{ widget.data.initial_text }}
{{ field.value.name }} {% if not widget.data.required %} {% endif %}
{% endif %} {% include 'bootstrap5/layout/help_text_and_errors.html' %} {% endif %} {% endfor %}