From 5a72589d7acb3abdd62e95bd30eba5ac038861a2 Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Tue, 26 Aug 2008 18:07:36 +0000 Subject: [PATCH] Fixed #7984 -- 'View on site' links now work in inlines. Thanks philwo for the report and initial patch by julianb. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8586 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/helpers.py | 3 +++ django/contrib/admin/templates/admin/edit_inline/stacked.html | 2 +- django/contrib/admin/templates/admin/edit_inline/tabular.html | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) 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 %} -

View on site

+

View on site

{% 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 or inline_admin_form.show_url %}

{% 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 %}