diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
index 77da4c0..ca4a7e4 100644
a
|
b
|
class AdminSite(object):
|
74 | 74 | admin options). If keyword arguments are given -- e.g., list_display -- |
75 | 75 | they'll be applied as options to the admin class. |
76 | 76 | |
| 77 | If a model is empty, this will raise ValueError. |
| 78 | |
77 | 79 | If a model is already registered, this will raise AlreadyRegistered. |
78 | 80 | |
79 | 81 | If a model is abstract, this will raise ImproperlyConfigured. |
80 | 82 | """ |
81 | 83 | if not admin_class: |
82 | 84 | admin_class = ModelAdmin |
83 | | |
| 85 | if not model_or_iterable: |
| 86 | raise ValueError('At least one model must be passed to register.') |
84 | 87 | if isinstance(model_or_iterable, ModelBase): |
85 | 88 | model_or_iterable = [model_or_iterable] |
86 | 89 | for model in model_or_iterable: |
… |
… |
class AdminSite(object):
|
113 | 116 | def unregister(self, model_or_iterable): |
114 | 117 | """ |
115 | 118 | Unregisters the given model(s). |
| 119 | |
| 120 | If a model is empty, this will raise ValueError. |
116 | 121 | |
117 | 122 | If a model isn't already registered, this will raise NotRegistered. |
118 | 123 | """ |
| 124 | if not model_or_iterable: |
| 125 | raise ValueError('At least one model must be passed to unregister.') |
119 | 126 | if isinstance(model_or_iterable, ModelBase): |
120 | 127 | model_or_iterable = [model_or_iterable] |
121 | 128 | for model in model_or_iterable: |
diff --git a/tests/admin_registration/tests.py b/tests/admin_registration/tests.py
index 202fed8..168cbf8 100644
a
|
b
|
class TestRegistration(SimpleTestCase):
|
70 | 70 | """ |
71 | 71 | self.assertRaises(ImproperlyConfigured, self.site.register, Location) |
72 | 72 | |
| 73 | def test_empty_models_list_registration(self): |
| 74 | with self.assertRaisesMessage(ValueError, 'At least one model must be passed to register.'):self.site.register(()) |
| 75 | |
73 | 76 | def test_is_registered_model(self): |
74 | 77 | "Checks for registered models should return true." |
75 | 78 | self.site.register(Person) |
… |
… |
class TestRegistration(SimpleTestCase):
|
79 | 82 | "Checks for unregistered models should return false." |
80 | 83 | self.assertFalse(self.site.is_registered(Person)) |
81 | 84 | |
| 85 | def test_empty_models_list_unregistration(self): |
| 86 | with self.assertRaisesMessage(ValueError, 'At least one model must be passed to unregister.'):self.site.unregister(()) |
| 87 | |
82 | 88 | |
83 | 89 | class TestRegistrationDecorator(SimpleTestCase): |
84 | 90 | """ |