{% 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 --- #} {# The wrapper carries is-invalid for the same reason as the plain branch #} {# below: Bootstrap only unhides .invalid-feedback next to an .is-invalid #} {# sibling, and this branch has no visible input to put the class on — so #} {# a rejected replacement file would fail silently. #}