Ticket #13782: 13782_errors_display.2.diff

File 13782_errors_display.2.diff, 2.3 KB (added by julien, 4 years ago)

Improved patch

  • django/contrib/admin/media/css/base.css

     
    496496    background: #ffc;
    497497}
    498498
    499 .errors input, .errors select {
     499.errors input, .errors select, .errors textarea {
    500500    border: 1px solid red;
    501501}
    502502
  • django/contrib/admin/helpers.py

     
    127127        attrs = classes and {'class': u' '.join(classes)} or {}
    128128        return self.field.label_tag(contents=contents, attrs=attrs)
    129129
     130    def errors(self):
     131        return mark_safe(self.field.errors.as_ul())
     132
    130133class AdminReadonlyField(object):
    131134    def __init__(self, form, field, is_first, model_admin=None):
    132135        label = label_for_field(field, form._meta.model, model_admin)
  • django/contrib/admin/templates/admin/includes/fieldset.html

     
    44        <div class="description">{{ fieldset.description|safe }}</div>
    55    {% endif %}
    66    {% for line in fieldset %}
    7         <div class="form-row{% if line.errors %} errors{% endif %}{% for field in line %} {{ field.field.name }}{% endfor %}">
    8             {{ line.errors }}
     7        <div class="form-row{% if line.fields|length_is:'1' and line.errors %} errors{% endif %}{% for field in line %} {{ field.field.name }}{% endfor %}">
     8            {% if line.fields|length_is:'1' %}{{ line.errors }}{% endif %}
    99            {% for field in line %}
    10                 <div{% if not line.fields|length_is:"1" %} class="field-box"{% endif %}>
     10                <div{% if not line.fields|length_is:'1' %} class="field-box{% if not field.is_readonly and field.errors %} errors{% endif %}"{% endif %}>
     11                    {% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %}
    1112                    {% if field.is_checkbox %}
    1213                        {{ field.field }}{{ field.label_tag }}
    1314                    {% else %}
Back to Top