diff options
| author | Loic Bistuer <loic.bistuer@sixmedia.com> | 2013-07-21 02:25:27 +0700 |
|---|---|---|
| committer | Loic Bistuer <loic.bistuer@sixmedia.com> | 2013-10-14 21:59:30 +0700 |
| commit | ac5ec7b8bcc5623cc05d4df900c39e194f5affcf (patch) | |
| tree | 63820b413bbd2e988d5bf5af41b53c03602ff3fc /django/forms/widgets.py | |
| parent | 54cd930baf49c45e3e91338a9f4a56d19090ff25 (diff) | |
Fixed #19617 -- Refactored Form metaclasses to support more inheritance scenarios.
Thanks apollo13, funkybob and mjtamlyn for the reviews.
Diffstat (limited to 'django/forms/widgets.py')
| -rw-r--r-- | django/forms/widgets.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 67befcfbe0..e80584a5c7 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -131,12 +131,16 @@ def media_property(cls): return property(_media) class MediaDefiningClass(type): - "Metaclass for classes that can have media definitions" - def __new__(cls, name, bases, attrs): - new_class = super(MediaDefiningClass, cls).__new__(cls, name, bases, - attrs) + """ + Metaclass for classes that can have media definitions. + """ + def __new__(mcs, name, bases, attrs): + new_class = (super(MediaDefiningClass, mcs) + .__new__(mcs, name, bases, attrs)) + if 'media' not in attrs: new_class.media = media_property(new_class) + return new_class @python_2_unicode_compatible |
