diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
index b995c0f..899a8a2 100644
a
|
b
|
class AdminSite(object):
|
78 | 78 | if model in self._registry: |
79 | 79 | raise AlreadyRegistered('The model %s is already registered' % model.__name__) |
80 | 80 | |
| 81 | if model._meta.abstract: |
| 82 | raise ValueError("Cannot register %s because it is an abstract model") |
| 83 | |
81 | 84 | # If we got **options then dynamically construct a subclass of |
82 | 85 | # admin_class with those **options. |
83 | 86 | if options: |
diff --git a/tests/regressiontests/admin_registration/models.py b/tests/regressiontests/admin_registration/models.py
index 4a2d4e9..ad786f5 100644
a
|
b
|
class Person(models.Model):
|
9 | 9 | |
10 | 10 | class Place(models.Model): |
11 | 11 | name = models.CharField(max_length=200) |
| 12 | |
| 13 | class AbstractModel(models.Model): |
| 14 | name = models.CharField(max_length=200) |
| 15 | class Meta: |
| 16 | abstract = True |
| 17 | |
| 18 | class ConcreteModel(AbstractModel): |
| 19 | description = models.CharField(max_length=200) |
diff --git a/tests/regressiontests/admin_registration/tests.py b/tests/regressiontests/admin_registration/tests.py
index e2a5d7e..f0cbd01 100644
a
|
b
|
from django.test import TestCase
|
2 | 2 | |
3 | 3 | from django.contrib import admin |
4 | 4 | |
5 | | from models import Person, Place |
| 5 | from models import Person, Place, AbstractModel, ConcreteModel |
6 | 6 | |
7 | 7 | class NameAdmin(admin.ModelAdmin): |
8 | 8 | list_display = ['name'] |
… |
… |
class TestRegistration(TestCase):
|
30 | 30 | self.site.register, |
31 | 31 | Person) |
32 | 32 | |
| 33 | def test_prevent_abstract_registration(self): |
| 34 | self.site.register(ConcreteModel) |
| 35 | self.assertRaises(ValueError, |
| 36 | self.site.register, |
| 37 | AbstractModel) |
| 38 | |
33 | 39 | def test_registration_with_star_star_options(self): |
34 | 40 | self.site.register(Person, search_fields=['name']) |
35 | 41 | self.assertEqual(self.site._registry[Person].search_fields, ['name']) |