=== django/newforms/formsets.py
==================================================================
|
|
|
|
| 87 | 87 | change_form = FormClass(**kwargs) |
| 88 | 88 | self.add_fields(change_form, i) |
| 89 | 89 | change_forms.append(change_form) |
| 90 | | self._change_forms= change_forms |
| | 90 | self._change_forms = change_forms |
| 91 | 91 | return self._change_forms |
| 92 | 92 | change_forms = property(_get_change_forms) |
| 93 | 93 | |
=== django/contrib/admin/options.py
==================================================================
|
|
|
|
| 521 | 521 | 'is_popup': request.REQUEST.has_key('_popup'), |
| 522 | 522 | 'show_delete': False, |
| 523 | 523 | 'media': media, |
| 524 | | 'inline_admin_formsets': inline_admin_formsets, |
| | 524 | 'inline_admin_formsets': InlineAdminFormSetList(inline_admin_formsets), |
| 525 | 525 | }) |
| 526 | 526 | return self.render_change_form(model, c, add=True) |
| 527 | 527 | |
| … |
… |
|
| 596 | 596 | 'original': obj, |
| 597 | 597 | 'is_popup': request.REQUEST.has_key('_popup'), |
| 598 | 598 | 'media': media, |
| 599 | | 'inline_admin_formsets': inline_admin_formsets, |
| | 599 | 'inline_admin_formsets': InlineAdminFormSetList(inline_admin_formsets), |
| 600 | 600 | }) |
| 601 | 601 | return self.render_change_form(model, c, change=True) |
| 602 | 602 | |
| … |
… |
|
| 766 | 766 | class TabularInline(InlineModelAdmin): |
| 767 | 767 | template = 'admin/edit_inline/tabular.html' |
| 768 | 768 | |
| | 769 | class InlineAdminFormSetList(object): |
| | 770 | def __init__(self, admin_formsets): |
| | 771 | self.admin_formsets = admin_formsets |
| | 772 | self.formsets = [ifs.formset for ifs in admin_formsets] |
| | 773 | |
| | 774 | def __iter__(self): |
| | 775 | return iter(self.admin_formsets) |
| | 776 | |
| | 777 | def _get_errors(self): |
| | 778 | errors = [] |
| | 779 | for formset in self.formsets: |
| | 780 | # HACK: a FormSet object does not always have an errors attribute. |
| | 781 | # this will work without the hasattr check for errors since its only |
| | 782 | # usage is in the template and variable resolution will suppress the |
| | 783 | # AttributeError exception thrown. |
| | 784 | if hasattr(formset, 'errors'): |
| | 785 | errors.append(formset.errors) |
| | 786 | return bool(errors) |
| | 787 | errors = property(_get_errors) |
| | 788 | |
| 769 | 789 | class InlineAdminFormSet(object): |
| 770 | 790 | """ |
| 771 | 791 | A wrapper around an inline formset for use in the admin system. |
=== django/contrib/admin/templates/admin/change_form.html
==================================================================
|
|
|
|
| 34 | 34 | <div> |
| 35 | 35 | {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %} |
| 36 | 36 | {% if save_on_top %}{% submit_row %}{% endif %} |
| 37 | | {% if adminform.form.errors %} |
| | 37 | {% if adminform.form.errors or inline_admin_formsets.errors %} |
| 38 | 38 | <p class="errornote"> |
| 39 | 39 | {% blocktrans count adminform.form.errors.items|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %} |
| 40 | 40 | </p> |