diff --git a/django/contrib/admin/decorators.py b/django/contrib/admin/decorators.py
index 5862bb5..27f0e74 100644
a
|
b
|
def register(*models, **kwargs):
|
9 | 9 | |
10 | 10 | A kwarg of `site` can be passed as the admin site, otherwise the default |
11 | 11 | admin site will be used. |
| 12 | |
| 13 | At least one model must be passed to register. |
12 | 14 | """ |
13 | 15 | from django.contrib.admin import ModelAdmin |
14 | 16 | from django.contrib.admin.sites import site, AdminSite |
… |
… |
def register(*models, **kwargs):
|
22 | 24 | if not issubclass(admin_class, ModelAdmin): |
23 | 25 | raise ValueError('Wrapped class must subclass ModelAdmin.') |
24 | 26 | |
| 27 | if not models: |
| 28 | raise ValueError('At least one model must be passed to register.') |
| 29 | |
25 | 30 | admin_site.register(models, admin_class=admin_class) |
26 | 31 | |
27 | 32 | return admin_class |
diff --git a/tests/admin_registration/tests.py b/tests/admin_registration/tests.py
index 7471c52..9e0b7fb 100644
a
|
b
|
class TestRegistrationDecorator(SimpleTestCase):
|
133 | 133 | def test_custom_site_not_an_admin_site(self): |
134 | 134 | self.assertRaisesMessage(ValueError, 'site must subclass AdminSite', |
135 | 135 | register(Person, site=Traveler), NameAdmin) |
| 136 | |
| 137 | def test_empty_list_registration_fails(self): |
| 138 | self.assertRaisesMessage(ValueError, 'At least one model must be passed to register.', |
| 139 | register(), NameAdmin) |
| 140 | |