Ticket #5628: 00-admin-errors.diff

File 00-admin-errors.diff, 2.2 KB (added by Petr Marhoun <petr.marhoun@…>, 16 years ago)

version with correct suffix

  • django/contrib/admin/options.py

    === modified file 'django/contrib/admin/options.py'
     
    522522            'show_delete': False,
    523523            'media': media,
    524524            'inline_admin_formsets': inline_admin_formsets,
     525            'errors': AdminErrorList(form, inline_formsets),
    525526        })
    526527        return self.render_change_form(model, c, add=True)
    527528   
     
    597598            'is_popup': request.REQUEST.has_key('_popup'),
    598599            'media': media,
    599600            'inline_admin_formsets': inline_admin_formsets,
     601            'errors': AdminErrorList(form, inline_formsets),
    600602        })
    601603        return self.render_change_form(model, c, change=True)
    602604
     
    805807    def ordering_field(self):
    806808        from django.newforms.formsets import ORDERING_FIELD_NAME
    807809        return AdminField(self.form, ORDERING_FIELD_NAME, False)
     810
     811class AdminErrorList(forms.util.ErrorList):
     812   
     813    def __init__(self, form, inline_formsets):
     814        if form.is_bound:
     815            self.extend(form.errors.values())
     816            for inline_formset in inline_formsets:
     817                self.extend(inline_formset.non_form_errors())
     818                for errors_in_inline_form in inline_formset.errors:
     819                    self.extend(errors_in_inline_form.values())
  • django/contrib/admin/templates/admin/change_form.html

    === modified file 'django/contrib/admin/templates/admin/change_form.html'
     
    3434<div>
    3535{% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
    3636{% if save_on_top %}{% submit_row %}{% endif %}
    37 {% if adminform.form.errors %}
     37{% if errors %}
    3838    <p class="errornote">
    39     {% blocktrans count adminform.form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
     39    {% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
     40    {{ adminform.form.non_field_errors }}
    4041    </p>
    4142{% endif %}
    4243
Back to Top