Possible bug in Media class.

11 views
Skip to first unread message

Roman Telezhynskyi

unread,
Oct 8, 2019, 12:53:27 PM10/8/19
to Django users
Hello,

Today for my project I tried to find a solution for an issue with duplicate assets. Combining several approaches I managed to build an app to solve it. While debugging the app, I think, I found a bug in Media class.

File django/forms/widgets.py

@html_safe
class Media:
   
def __init__(self, media=None, css=None, js=None):
       
if media is not None:
            css
= getattr(media, 'css', {})
            js
= getattr(media, 'js', [])
       
else:
           
if css is None:
                css
= {}
           
if js is None:
                js
= []
       
self._css_lists = [css]
       
self._js_lists = [js]

These two strings seems incorrect.
css = getattr(media, 'css', {})
js
= getattr(media, 'js', [])

Instead of css and js attributes they return default values. I feel like it is just a developer error. If replace strings with
css = getattr(media, '_css', {})
js
= getattr(media, '_js', [])
everything works again.

Can somebody confirm my guess?
Reply all
Reply to author
Forward
0 new messages