Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#8072 closed (duplicate)

NFA: Valid fieldsets are marked as 'error'.

Reported by: niksite Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: nfa
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


If more than one field is places on one line in the NFA, this line of fields has class 'error' and e.g. this fieldset cannot be collapsed.

This is because the following line of the django/contrib/admin/

92 	    def errors(self):
93 	        return mark_safe(u'\n'.join([self.form[f].errors.as_ul() for f in self.fields]))

For more than one fields, this code has generated '\n'.

Let's see to the django/contrib/admin/templates/admin/includes/fieldset.html:

5 	      <div class="form-row{% if line.errors %} errors{% endif %} {% for field in line %}{{ }} {% endfor %} ">

The "\n" is True in this context, so "errors" class has illegally associated with this "div".

This issue can be easily fixed by the following patch:

Index: django/contrib/admin/
--- django/contrib/admin/	(revision 8168)
+++ django/contrib/admin/	(working copy)
@@ -89,7 +89,7 @@
             yield AdminField(self.form, field, is_first=(i == 0))
     def errors(self):
-        return mark_safe(u'\n'.join([self.form[f].errors.as_ul() for f in self.fields]))
+        return mark_safe(u'\n'.join([self.form[f].errors.as_ul() for f in self.fields].strip()))
 class AdminField(object):
     def __init__(self, form, field, is_first):

Change History (2)

comment:1 Changed 7 years ago by Karen Tracey <kmtracey@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Already reported in #5631, which has the same patch.

comment:2 Changed 4 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

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