Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #7984 -- 'View on site' links now work in inlines. Thanks philw…

…o for the report and initial patch by julianb.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8586 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5a72589d7acb3abdd62e95bd30eba5ac038861a2 1 parent 05a4439
@brosner brosner authored
View
3  django/contrib/admin/helpers.py
@@ -5,6 +5,7 @@
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)
View
2  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 %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
</h3>
{% if inline_admin_form.show_url %}
- <p><a href="/r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/">View on site</a></p>
+ <p><a href="../../../r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/">View on site</a></p>
{% endif %}
{% for fieldset in inline_admin_form %}
View
2  django/contrib/admin/templates/admin/edit_inline/tabular.html
@@ -22,7 +22,7 @@
<td class="original">
{% if inline_admin_form.original or inline_admin_form.show_url %}<p>
{% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %}
- {% if inline_admin_form.show_url %}<a href="/r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/">View on site</a>{% endif %}
+ {% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original.content_type_id }}/{{ inline_admin_form.original.id }}/">View on site</a>{% endif %}
</p>{% endif %}
{{ inline_admin_form.pk_field.field }}
{% spaceless %}

0 comments on commit 5a72589

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