#8072 closed (duplicate)
NFA: Valid fieldsets are marked as 'error'.
Reported by: | Nikolay | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | nfa | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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/options.py:
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 %}{{ field.field.name }} {% 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/options.py =================================================================== --- django/contrib/admin/options.py (revision 8168) +++ django/contrib/admin/options.py (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):
Note:
See TracTickets
for help on using tickets.
Already reported in #5631, which has the same patch.