diff --git a/tests/admin_inlines/admin.py b/tests/admin_inlines/admin.py
index b5f343a55b..d53bdc06a3 100644
a
|
b
|
site.register(Holder, HolderAdmin, inlines=[InnerInline])
|
242 | 242 | # ModelAdmin and Inline media |
243 | 243 | site.register(Holder2, HolderAdmin, inlines=[InnerInline2, InnerInline2Tabular]) |
244 | 244 | # only Inline media |
245 | | site.register(Holder3, inlines=[InnerInline3]) |
| 245 | site.register(Holder3, inlines=[InnerInline3], filter_horizontal=['categories']) |
246 | 246 | |
247 | 247 | site.register(Poll, PollAdmin) |
248 | 248 | site.register(Novel, NovelAdmin) |
diff --git a/tests/admin_inlines/models.py b/tests/admin_inlines/models.py
index 38b2999f79..019470a147 100644
a
|
b
|
Testing of admin inline formsets.
|
3 | 3 | """ |
4 | 4 | import random |
5 | 5 | |
| 6 | from django import forms |
6 | 7 | from django.contrib.contenttypes.fields import GenericForeignKey |
7 | 8 | from django.contrib.contenttypes.models import ContentType |
8 | 9 | from django.db import models |
… |
… |
class Inner2(models.Model):
|
88 | 89 | holder = models.ForeignKey(Holder2, models.CASCADE) |
89 | 90 | |
90 | 91 | |
| 92 | class CustomNumberInput(forms.NumberInput): |
| 93 | class Media: |
| 94 | js = ("custom_number.js",) |
| 95 | |
| 96 | |
| 97 | class CustomIntegerField(models.IntegerField): |
| 98 | def formfield(self, **kwargs): |
| 99 | kwargs["widget"] = CustomNumberInput |
| 100 | return super().formfield(**kwargs) |
| 101 | |
| 102 | |
| 103 | class Holder3Category(models.Model): |
| 104 | title = models.CharField(max_length=100) |
| 105 | |
| 106 | |
91 | 107 | class Holder3(models.Model): |
92 | | dummy = models.IntegerField() |
| 108 | # The ordering of those two fields is important. |
| 109 | # https://code.djangoproject.com/ticket/30153 |
| 110 | dummy = CustomIntegerField() |
| 111 | categories = models.ManyToManyField(Holder3Category, blank=True) |
93 | 112 | |
94 | 113 | |
95 | 114 | class Inner3(models.Model): |
96 | | dummy = models.IntegerField() |
| 115 | dummy = CustomIntegerField() |
97 | 116 | holder = models.ForeignKey(Holder3, models.CASCADE) |
98 | 117 | |
99 | 118 | # Models for ticket #8190 |
diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py
index 0a1ab5acbb..21ea2ac968 100644
a
|
b
|
class TestInlineMedia(TestDataMixin, TestCase):
|
505 | 505 | ) |
506 | 506 | self.assertContains(response, 'my_awesome_inline_scripts.js') |
507 | 507 | |
| 508 | self.assertEqual( |
| 509 | response.context["media"]._js, |
| 510 | [ |
| 511 | 'admin/js/vendor/jquery/jquery.min.js', |
| 512 | 'admin/js/jquery.init.js', |
| 513 | 'admin/js/core.js', |
| 514 | 'admin/js/admin/RelatedObjectLookups.js', |
| 515 | 'admin/js/actions.min.js', |
| 516 | 'admin/js/urlify.js', |
| 517 | 'admin/js/prepopulate.min.js', |
| 518 | 'admin/js/vendor/xregexp/xregexp.min.js', |
| 519 | 'admin/js/inlines.min.js', |
| 520 | 'my_awesome_inline_scripts.js', |
| 521 | 'custom_number.js', |
| 522 | ], |
| 523 | ) |
| 524 | |
508 | 525 | def test_all_inline_media(self): |
509 | 526 | holder = Holder2(dummy=13) |
510 | 527 | holder.save() |