diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 061988c..06132c6 100644
a
|
b
|
try:
|
11 | 11 | from urllib.parse import urljoin |
12 | 12 | except ImportError: # Python 2 |
13 | 13 | from urlparse import urljoin |
| 14 | from inspect import getmembers |
14 | 15 | |
15 | 16 | from django.conf import settings |
16 | 17 | from django.forms.util import flatatt, to_current_timezone |
… |
… |
MEDIA_TYPES = ('css','js')
|
36 | 37 | class Media(object): |
37 | 38 | def __init__(self, media=None, **kwargs): |
38 | 39 | if media: |
39 | | media_attrs = media.__dict__ |
| 40 | media_attrs = dict(getmembers(media)) |
40 | 41 | else: |
41 | 42 | media_attrs = kwargs |
42 | 43 | |
diff --git a/tests/regressiontests/forms/tests/media.py b/tests/regressiontests/forms/tests/media.py
index c492a1e..028ff6b 100644
a
|
b
|
class FormsMediaTestCase(TestCase):
|
285 | 285 | <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script> |
286 | 286 | <script type="text/javascript" src="/path/to/js4"></script>""") |
287 | 287 | |
| 288 | class BaseMedia: |
| 289 | css = {"all": ["/path/to/css"]} |
| 290 | |
| 291 | class ExtendWidget(TextInput): |
| 292 | class Media(BaseMedia): |
| 293 | js = ["/path/to/js"] |
| 294 | |
| 295 | extend_widget = ExtendWidget() |
| 296 | |
| 297 | self.assertEqual(str(extend_widget.media), """<link href="/path/to/css" type="text/css" media="all" rel="stylesheet" /> |
| 298 | <script type="text/javascript" src="/path/to/js"></script>""") |
| 299 | |
288 | 300 | def test_media_inheritance_single_type(self): |
289 | 301 | # A widget can enable inheritance of one media type by specifying extend as a tuple |
290 | 302 | class MyWidget1(TextInput): |