diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py index ba49f8b7cf..da0925f4b5 100644 --- a/django/contrib/admin/helpers.py +++ b/django/contrib/admin/helpers.py @@ -5,6 +5,7 @@ from django.utils.html import escape from django.utils.safestring import mark_safe from django.utils.encoding import force_unicode from django.contrib.admin.util import flatten_fieldsets +from django.contrib.contenttypes.models import ContentType class AdminForm(object): def __init__(self, form, fieldsets, prepopulated_fields): @@ -114,6 +115,8 @@ class InlineAdminForm(AdminForm): def __init__(self, formset, form, fieldsets, prepopulated_fields, original): self.formset = formset self.original = original + if original is not None: + 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) diff --git a/django/contrib/admin/templates/admin/edit_inline/stacked.html b/django/contrib/admin/templates/admin/edit_inline/stacked.html index 217791f658..cd0430c01a 100644 --- a/django/contrib/admin/templates/admin/edit_inline/stacked.html +++ b/django/contrib/admin/templates/admin/edit_inline/stacked.html @@ -10,7 +10,7 @@ {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}{% endif %} {% if inline_admin_form.show_url %} -
+ {% endif %} {% for fieldset in inline_admin_form %} diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html index f3fe378934..9ad93146ba 100644 --- a/django/contrib/admin/templates/admin/edit_inline/tabular.html +++ b/django/contrib/admin/templates/admin/edit_inline/tabular.html @@ -22,7 +22,7 @@{% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %} - {% if inline_admin_form.show_url %}View on site{% endif %} + {% if inline_admin_form.show_url %}View on site{% endif %}
{% endif %} {{ inline_admin_form.pk_field.field }} {% spaceless %}