diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py index 00e1f88dabb..a0d3237806b 100644 --- a/django/contrib/admin/helpers.py +++ b/django/contrib/admin/helpers.py @@ -129,6 +129,16 @@ class InlineAdminForm(AdminForm): 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) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 019bfe97896..c9d94896803 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -585,6 +585,7 @@ class ModelAdmin(BaseModelAdmin): 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 @@ class ModelAdmin(BaseModelAdmin): 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, diff --git a/django/contrib/admin/templates/admin/edit_inline/stacked.html b/django/contrib/admin/templates/admin/edit_inline/stacked.html index ecc3dca8ace..840c1293e12 100644 --- a/django/contrib/admin/templates/admin/edit_inline/stacked.html +++ b/django/contrib/admin/templates/admin/edit_inline/stacked.html @@ -12,6 +12,7 @@ {% if inline_admin_form.show_url %}
{% 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" %} diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html index e21cf10dea5..25dbe763f8f 100644 --- a/django/contrib/admin/templates/admin/edit_inline/tabular.html +++ b/django/contrib/admin/templates/admin/edit_inline/tabular.html @@ -16,7 +16,9 @@ {% for inline_admin_form in inline_admin_formset %} - + {% if inline_admin_form.form.non_field_errors %} +