Display non_field_errors of inline forms in the admin. This was a presentation bug.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9243 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ae43d11838
commit
5e5af8a8aa
|
@ -130,6 +130,16 @@ class InlineAdminForm(AdminForm):
|
||||||
self.show_url = original and hasattr(original, 'get_absolute_url')
|
self.show_url = original and hasattr(original, 'get_absolute_url')
|
||||||
super(InlineAdminForm, self).__init__(form, fieldsets, prepopulated_fields)
|
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):
|
def pk_field(self):
|
||||||
return AdminField(self.form, self.formset._pk_field.name, False)
|
return AdminField(self.form, self.formset._pk_field.name, False)
|
||||||
|
|
||||||
|
|
|
@ -585,6 +585,7 @@ class ModelAdmin(BaseModelAdmin):
|
||||||
change_message = self.construct_change_message(request, form, formsets)
|
change_message = self.construct_change_message(request, form, formsets)
|
||||||
self.log_change(request, new_object, change_message)
|
self.log_change(request, new_object, change_message)
|
||||||
return self.response_change(request, new_object)
|
return self.response_change(request, new_object)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form = ModelForm(instance=obj)
|
form = ModelForm(instance=obj)
|
||||||
for FormSet in self.get_formsets(request, obj):
|
for FormSet in self.get_formsets(request, obj):
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
{% if inline_admin_form.show_url %}
|
{% 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>
|
<p><a href="../../../r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/">{% trans "View on site" %}</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %}
|
||||||
|
|
||||||
{% for fieldset in inline_admin_form %}
|
{% for fieldset in inline_admin_form %}
|
||||||
{% include "admin/includes/fieldset.html" %}
|
{% include "admin/includes/fieldset.html" %}
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
|
|
||||||
{% for inline_admin_form in inline_admin_formset %}
|
{% 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 %}">
|
<tr class="{% cycle row1,row2 %} {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}">
|
||||||
|
|
||||||
<td class="original">
|
<td class="original">
|
||||||
|
|
Loading…
Reference in New Issue