mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #19425 - Added InlineModelAdmin.get_extra hook.
Thanks dave@ for the suggestion and Rohan Jain for the patch.
This commit is contained in:
@@ -12,7 +12,7 @@ from .admin import InnerInline, TitleInline, site
|
||||
from .models import (Holder, Inner, Holder2, Inner2, Holder3, Inner3, Person,
|
||||
OutfitItem, Fashionista, Teacher, Parent, Child, Author, Book, Profile,
|
||||
ProfileCollection, ParentModelWithCustomPk, ChildModel1, ChildModel2,
|
||||
Sighting, Title, Novel, Chapter, FootNote)
|
||||
Sighting, Title, Novel, Chapter, FootNote, BinaryTree)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
@@ -193,6 +193,18 @@ class TestInline(TestCase):
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(Sighting.objects.filter(et__name='Martian').count(), 1)
|
||||
|
||||
def test_custom_get_extra_form(self):
|
||||
bt_head = BinaryTree.objects.create(name="Tree Head")
|
||||
bt_child = BinaryTree.objects.create(name="First Child", parent=bt_head)
|
||||
|
||||
# The total number of forms will remain the same in either case
|
||||
total_forms_hidden = '<input id="id_binarytree_set-TOTAL_FORMS" name="binarytree_set-TOTAL_FORMS" type="hidden" value="2" />'
|
||||
response = self.client.get('/admin/admin_inlines/binarytree/add/')
|
||||
self.assertContains(response, total_forms_hidden)
|
||||
|
||||
response = self.client.get("/admin/admin_inlines/binarytree/%d/" % bt_head.id)
|
||||
self.assertContains(response, total_forms_hidden)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
class TestInlineMedia(TestCase):
|
||||
|
||||
Reference in New Issue
Block a user