Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#11681 closed (fixed)

HTML validation failure in admin/change_form.html because of errorlist ul

Reported by: rlaager@… Owned by: nessita
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The admin app's change form fails to validate if there are model errors. This happens because {% if errors %} passes, but then (at least in this case) there is nothing in adminform.form.non_field_errors, so an empty <ul> is produced. The attached patch fixes it for me.

Attachments (2)

errorlist.diff (822 bytes) - added by rlaager@… 6 years ago.
patch-11681.diff (1.5 KB) - added by nessita 5 years ago.
Removing surronding HTML tags for non_field_errors and for non_form_errors

Download all attachments as: .zip

Change History (10)

Changed 6 years ago by rlaager@…

comment:1 Changed 6 years ago by dc

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement set

Better use something like

{% if adminform.form.non_field_errors %}
    <ul class="errorlist">{% for error in adminform.form.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
{% endif %}

than two additional checks every iteration.

comment:2 Changed 6 years ago by russellm

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 5 years ago by nessita

  • Owner changed from nobody to nessita
  • Status changed from new to assigned

Actually, I think this problem is a bit different. non_field_errors is already a properly HTML formatted list, so there is no need to add the HTML tags in the change_form.html template.

Changed 5 years ago by nessita

Removing surronding HTML tags for non_field_errors and for non_form_errors

comment:4 Changed 5 years ago by nessita

  • Patch needs improvement unset

comment:5 Changed 5 years ago by Alex

  • milestone set to 1.2
  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 5 years ago by jkocherhans

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed by [12541].

comment:7 Changed 5 years ago by jkocherhans

(In [12542]) [1.1.X] Fixed #11681. Fixed display of non_field_errors and non_form_errors in the admin. Backport of r12541 from trunk.

comment:8 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top