From ede49c7ee03dd1519d0c375d953cb73e106837b6 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 6 Aug 2012 07:58:54 -0700 Subject: [PATCH] Fixed #15754 -- avoid recursively computing the tree of media widgets more times than is necessary for a wiget --- django/forms/widgets.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 6b1be37ec27..3c4da2444df 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -110,9 +110,10 @@ class Media(StrAndUnicode): def media_property(cls): def _media(self): # Get the media property of the superclass, if it exists - if hasattr(super(cls, self), 'media'): - base = super(cls, self).media - else: + sup_cls = super(cls, self) + try: + base = sup_cls.media + except AttributeError: base = Media() # Get the media definition for this class