Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.0.X] Display non_field_errors of inline forms in the admin. This w…

…as a presentation bug.

Backport of [9243] from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9244 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d7ebda8d08f0b50e5cda216d562f14701731164b 1 parent 118383c
@brosner brosner authored
View
10 django/contrib/admin/helpers.py
@@ -129,6 +129,16 @@ def __init__(self, formset, form, fieldsets, prepopulated_fields, original):
self.original.content_type_id = ContentType.objects.get_for_model(original).pk
self.show_url = original and hasattr(original, 'get_absolute_url')
super(InlineAdminForm, self).__init__(form, fieldsets, prepopulated_fields)
+
+ def field_count(self):
+ # tabular.html uses this function for colspan value.
+ num_of_fields = 1 # always has at least one field
+ num_of_fields += len(self.fieldsets[0][1]["fields"])
+ if self.formset.can_order:
+ num_of_fields += 1
+ if self.formset.can_delete:
+ num_of_fields += 1
+ return num_of_fields
def pk_field(self):
return AdminField(self.form, self.formset._pk_field.name, False)
View
3  django/contrib/admin/options.py
@@ -585,6 +585,7 @@ def change_view(self, request, object_id, extra_context=None):
change_message = self.construct_change_message(request, form, formsets)
self.log_change(request, new_object, change_message)
return self.response_change(request, new_object)
+
else:
form = ModelForm(instance=obj)
for FormSet in self.get_formsets(request, obj):
@@ -600,7 +601,7 @@ def change_view(self, request, object_id, extra_context=None):
inline_admin_formset = helpers.InlineAdminFormSet(inline, formset, fieldsets)
inline_admin_formsets.append(inline_admin_formset)
media = media + inline_admin_formset.media
-
+
context = {
'title': _('Change %s') % force_unicode(opts.verbose_name),
'adminform': adminForm,
View
1  django/contrib/admin/templates/admin/edit_inline/stacked.html
@@ -12,6 +12,7 @@
{% if inline_admin_form.show_url %}
<p><a href="../../../r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/">{% trans "View on site" %}</a></p>
{% endif %}
+ {% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %}
{% for fieldset in inline_admin_form %}
{% include "admin/includes/fieldset.html" %}
View
4 django/contrib/admin/templates/admin/edit_inline/tabular.html
@@ -16,7 +16,9 @@
</tr></thead>
{% for inline_admin_form in inline_admin_formset %}
-
+ {% if inline_admin_form.form.non_field_errors %}
+ <tr><td colspan="{{ inline_admin_form.field_count }}">{{ inline_admin_form.form.non_field_errors }}</td></tr>
+ {% endif %}
<tr class="{% cycle row1,row2 %} {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}">
<td class="original">

0 comments on commit d7ebda8

Please sign in to comment.
Something went wrong with that request. Please try again.