diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 8cc27c5..78be4ad 100644
a
|
b
|
class BaseModelAdmin(object):
|
107 | 107 | |
108 | 108 | # If we've got overrides for the formfield defined, use 'em. **kwargs |
109 | 109 | # passed to formfield_for_dbfield override the defaults. |
110 | | if db_field.__class__ in self.formfield_overrides: |
111 | | kwargs = dict(self.formfield_overrides[db_field.__class__], **kwargs) |
112 | | return db_field.formfield(**kwargs) |
| 110 | for klass in db_field.__class__.mro(): |
| 111 | if klass in self.formfield_overrides: |
| 112 | kwargs = dict(self.formfield_overrides[klass], **kwargs) |
| 113 | return db_field.formfield(**kwargs) |
113 | 114 | |
114 | 115 | # For any other type of field, just call its formfield() method. |
115 | 116 | return db_field.formfield(**kwargs) |
diff --git a/tests/regressiontests/admin_widgets/models.py b/tests/regressiontests/admin_widgets/models.py
index 1ba759b..66d30bc 100644
a
|
b
|
from django.db import models
|
4 | 4 | from django.core.files.storage import default_storage |
5 | 5 | from django.contrib.auth.models import User |
6 | 6 | |
| 7 | class MyFileField(models.FileField): |
| 8 | pass |
| 9 | |
7 | 10 | class Member(models.Model): |
8 | 11 | name = models.CharField(max_length=100) |
9 | 12 | birthdate = models.DateTimeField(blank=True, null=True) |
… |
… |
class Album(models.Model):
|
23 | 26 | band = models.ForeignKey(Band) |
24 | 27 | name = models.CharField(max_length=100) |
25 | 28 | cover_art = models.FileField(upload_to='albums') |
| 29 | backside_art = MyFileField(upload_to='albums_back', null=True) |
26 | 30 | |
27 | 31 | def __unicode__(self): |
28 | 32 | return self.name |
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
index c2b0403..1559d2b 100644
a
|
b
|
class AdminFormfieldForDBFieldTests(TestCase):
|
98 | 98 | self.assertFormfield(models.Member, 'gender', widgets.AdminRadioSelect, |
99 | 99 | radio_fields={'gender':admin.VERTICAL}) |
100 | 100 | |
| 101 | def testInheritance(self): |
| 102 | self.assertFormfield(models.Album, 'backside_art', widgets.AdminFileWidget) |
| 103 | |
101 | 104 | |
102 | 105 | class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase): |
103 | 106 | fixtures = ["admin-widgets-users.xml"] |
… |
… |
class AdminFormfieldForDBFieldWithRequestTests(DjangoTestCase):
|
113 | 116 | |
114 | 117 | class AdminForeignKeyWidgetChangeList(DjangoTestCase): |
115 | 118 | fixtures = ["admin-widgets-users.xml"] |
116 | | |
| 119 | |
117 | 120 | def setUp(self): |
118 | 121 | self.client.login(username="super", password="secret") |
119 | | |
| 122 | |
120 | 123 | def tearDown(self): |
121 | 124 | self.client.logout() |
122 | | |
| 125 | |
123 | 126 | def test_changelist_foreignkey(self): |
124 | 127 | response = self.client.get('/widget_admin/admin_widgets/car/') |
125 | 128 | self.failUnless('/widget_admin/auth/user/add/' in response.content) |