Tuesday, October 8, 2019

Possible bug in Media class.

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?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9fcba07c-7c12-4c6c-b266-e2a8e0318afa%40googlegroups.com.

No comments:

Post a Comment