Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WidgetMixin __init__ breaks when attrs is None #1334

Open
oberix opened this issue Aug 8, 2023 · 1 comment
Open

WidgetMixin __init__ breaks when attrs is None #1334

oberix opened this issue Aug 8, 2023 · 1 comment

Comments

@oberix
Copy link

oberix commented Aug 8, 2023

Hello, I found this unexpected behavior when using ListSelect2 in a MultiWidget. Basically __init__ breaks if attrs is None.

Django MultiWidget has the following signature

def __init__(self, widgets, attrs=None):
    ...

But in dal.widgets.WidgetMixin.__init__ happens this

def __init__(self, url=None, forward=None, *args, **kwargs):
     ...
     self.placeholder = kwargs.get("attrs", {}).get("data-placeholder")
     ...

In other words WidgetMixin assume attrs is either a dict or is not in kwargs, but in the base class Widgets it defaults to None.

Not a big dial, it can be easily worked around, but I think that it should be allowed to blindly pass attrs to all subwidget of a MultiWidget (that's what works with a plain Select at last).

Regards

@jpic
Copy link
Member

jpic commented Jan 9, 2024

Agreed, None should be supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants