mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #25688 -- Made admin.register() disallow an empty list of models.
This commit is contained in:
parent
c550beb0cc
commit
8c553e7d3f
@ -14,6 +14,9 @@ def register(*models, **kwargs):
|
||||
from django.contrib.admin.sites import site, AdminSite
|
||||
|
||||
def _model_admin_wrapper(admin_class):
|
||||
if not models:
|
||||
raise ValueError('At least one model must be passed to register.')
|
||||
|
||||
admin_site = kwargs.pop('site', site)
|
||||
|
||||
if not isinstance(admin_site, AdminSite):
|
||||
|
@ -133,3 +133,7 @@ class TestRegistrationDecorator(SimpleTestCase):
|
||||
def test_custom_site_not_an_admin_site(self):
|
||||
self.assertRaisesMessage(ValueError, 'site must subclass AdminSite',
|
||||
register(Person, site=Traveler), NameAdmin)
|
||||
|
||||
def test_empty_models_list_registration_fails(self):
|
||||
with self.assertRaisesMessage(ValueError, 'At least one model must be passed to register.'):
|
||||
register()(NameAdmin)
|
||||
|
Loading…
Reference in New Issue
Block a user