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
This commit is contained in:
parent
05a4439581
commit
5a72589d7a
|
@ -5,6 +5,7 @@ from django.utils.html import escape
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.encoding import force_unicode
|
from django.utils.encoding import force_unicode
|
||||||
from django.contrib.admin.util import flatten_fieldsets
|
from django.contrib.admin.util import flatten_fieldsets
|
||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
|
||||||
class AdminForm(object):
|
class AdminForm(object):
|
||||||
def __init__(self, form, fieldsets, prepopulated_fields):
|
def __init__(self, form, fieldsets, prepopulated_fields):
|
||||||
|
@ -114,6 +115,8 @@ class InlineAdminForm(AdminForm):
|
||||||
def __init__(self, formset, form, fieldsets, prepopulated_fields, original):
|
def __init__(self, formset, form, fieldsets, prepopulated_fields, original):
|
||||||
self.formset = formset
|
self.formset = formset
|
||||||
self.original = original
|
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')
|
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)
|
||||||
|
|
||||||
|
|
|
@ -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 %}
|
{% 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>
|
</h3>
|
||||||
{% 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 }}/">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 %}
|
{% endif %}
|
||||||
|
|
||||||
{% for fieldset in inline_admin_form %}
|
{% for fieldset in inline_admin_form %}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<td class="original">
|
<td class="original">
|
||||||
{% if inline_admin_form.original or inline_admin_form.show_url %}<p>
|
{% 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.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 %}
|
</p>{% endif %}
|
||||||
{{ inline_admin_form.pk_field.field }}
|
{{ inline_admin_form.pk_field.field }}
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
|
|
Loading…
Reference in New Issue