Ticket #5628: 00-admin-errors

File 00-admin-errors, 2.2 KB (added by Petr Marhoun <petr.marhoun@…>, 17 years ago)
Line 
1=== modified file 'django/contrib/admin/options.py'
2--- django/contrib/admin/options.py 2007-11-13 02:22:09 +0000
3+++ django/contrib/admin/options.py 2007-11-13 02:15:40 +0000
4@@ -522,6 +522,7 @@
5 'show_delete': False,
6 'media': media,
7 'inline_admin_formsets': inline_admin_formsets,
8+ 'errors': AdminErrorList(form, inline_formsets),
9 })
10 return self.render_change_form(model, c, add=True)
11
12@@ -597,6 +598,7 @@
13 'is_popup': request.REQUEST.has_key('_popup'),
14 'media': media,
15 'inline_admin_formsets': inline_admin_formsets,
16+ 'errors': AdminErrorList(form, inline_formsets),
17 })
18 return self.render_change_form(model, c, change=True)
19
20@@ -805,3 +807,13 @@
21 def ordering_field(self):
22 from django.newforms.formsets import ORDERING_FIELD_NAME
23 return AdminField(self.form, ORDERING_FIELD_NAME, False)
24+
25+class AdminErrorList(forms.util.ErrorList):
26+
27+ def __init__(self, form, inline_formsets):
28+ if form.is_bound:
29+ self.extend(form.errors.values())
30+ for inline_formset in inline_formsets:
31+ self.extend(inline_formset.non_form_errors())
32+ for errors_in_inline_form in inline_formset.errors:
33+ self.extend(errors_in_inline_form.values())
34
35=== modified file 'django/contrib/admin/templates/admin/change_form.html'
36--- django/contrib/admin/templates/admin/change_form.html 2007-11-13 02:22:08 +0000
37+++ django/contrib/admin/templates/admin/change_form.html 2007-11-13 02:15:40 +0000
38@@ -34,9 +34,10 @@
39 <div>
40 {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
41 {% if save_on_top %}{% submit_row %}{% endif %}
42-{% if adminform.form.errors %}
43+{% if errors %}
44 <p class="errornote">
45- {% blocktrans count adminform.form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
46+ {% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
47+ {{ adminform.form.non_field_errors }}
48 </p>
49 {% endif %}
50
51
Back to Top