Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #21382 - Added "has_original" to stacked inlines.

Report and original patch from jrief.
  • Loading branch information...
commit d25622000ac8a591101ade28708d3b4b8ae4b24f 1 parent 1b29d32
@ryankask ryankask authored timgraham committed
View
2  django/contrib/admin/templates/admin/edit_inline/stacked.html
@@ -4,7 +4,7 @@
{{ inline_admin_formset.formset.management_form }}
{{ inline_admin_formset.formset.non_form_errors }}
-{% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
+{% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if inline_admin_form.original or inline_admin_form.show_url %} has_original{% endif %}{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
<h3><b>{{ inline_admin_formset.opts.verbose_name|capfirst }}:</b>&nbsp;<span class="inline_label">{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %}#{{ forloop.counter }}{% endif %}</span>
{% if inline_admin_form.show_url %}<a href="{{ inline_admin_form.absolute_url }}">{% trans "View on site" %}</a>{% 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 %}
View
15 tests/admin_inlines/tests.py
@@ -239,6 +239,21 @@ def test_inline_editable_pk(self):
'<input class="vIntegerField" id="id_editablepkbook_set-2-0-manual_pk" name="editablepkbook_set-2-0-manual_pk" type="text" />',
html=True, count=1)
+ def test_stacked_inline_edit_form_contains_has_original_class(self):
+ holder = Holder.objects.create(dummy=1)
+ holder.inner_set.create(dummy=1)
+ response = self.client.get('/admin/admin_inlines/holder/%s/' % holder.pk)
+ self.assertContains(
+ response,
+ '<div class="inline-related has_original" id="inner_set-0">',
+ count=1
+ )
+ self.assertContains(
+ response,
+ '<div class="inline-related" id="inner_set-1">',
+ count=1
+ )
+
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
class TestInlineMedia(TestCase):
Please sign in to comment.
Something went wrong with that request. Please try again.