diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 6d5c0708a3..22374be658 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1940,6 +1940,7 @@ class ModelAdmin(BaseModelAdmin): "inline_admin_formsets": inline_formsets, "errors": helpers.AdminErrorList(form, formsets), "preserved_filters": self.get_preserved_filters(request), + "field_errors_exist": form._field_errors_exist, } # Hide the "Save" and "Save and continue" buttons if "Save as New" was diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html index 298fe91e8d..2ad2b7e103 100644 --- a/django/contrib/admin/templates/admin/change_form.html +++ b/django/contrib/admin/templates/admin/change_form.html @@ -25,27 +25,27 @@ {% block pretitle %} {% if errors %} -

- {% blocktranslate count counter=errors|length %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktranslate %} -

- - {{ adminform.form.non_field_errors }} - -
-

The following fields have errors

+ {% endif %} {% endblock %} @@ -85,6 +85,24 @@ {% block submit_buttons_bottom %}{% submit_row %}{% endblock %} {% block admin_change_form_document_ready %} +{% if errors %} + +{% endif %} +