[Django] #32341: forms.ModelMultipleChoiceField raising TypeError when empty_label provided

14 views
Skip to first unread message

Django

unread,
Jan 10, 2021, 8:28:44 PM1/10/21
to django-...@googlegroups.com
#32341: forms.ModelMultipleChoiceField raising TypeError when empty_label provided
-------------------------------------+-------------------------------------
Reporter: thewamz | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 3.1
Severity: Release | Keywords:
blocker | ModelMultipleChoiceField
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
In a django form, when I set a value for the `empty_label` parameter, a
TypeError is raised. TypeError: __init__() got multiple values for keyword
argument 'empty_label'

```
field_name = forms.ModelMultipleChoiceField(
label="Field Label",
queryset=MyModel.objects.all(),
empty_label="Select something",
)
```

--
Ticket URL: <https://code.djangoproject.com/ticket/32341>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 10, 2021, 8:29:57 PM1/10/21
to django-...@googlegroups.com
#32341: forms.ModelMultipleChoiceField raising TypeError when empty_label provided
-------------------------------------+-------------------------------------
Reporter: thewamz | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
ModelMultipleChoiceField | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Description changed by thewamz:

Old description:

> In a django form, when I set a value for the `empty_label` parameter, a
> TypeError is raised. TypeError: __init__() got multiple values for
> keyword argument 'empty_label'
>
> ```
> field_name = forms.ModelMultipleChoiceField(
> label="Field Label",
> queryset=MyModel.objects.all(),
> empty_label="Select something",
> )
> ```

New description:

In a django form, when I set a value for the `empty_label` parameter, a
TypeError is raised. TypeError: __init__() got multiple values for keyword
argument 'empty_label'

`field_name =
forms.ModelMultipleChoiceField(queryset=MyModel.objects.all(),
empty_label="Select something" )`

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32341#comment:1>

Django

unread,
Jan 10, 2021, 8:30:10 PM1/10/21
to django-...@googlegroups.com
#32341: forms.ModelMultipleChoiceField raising TypeError when empty_label provided
-------------------------------------+-------------------------------------
Reporter: thewamz | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
ModelMultipleChoiceField | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Description changed by thewamz:

Old description:

> In a django form, when I set a value for the `empty_label` parameter, a


> TypeError is raised. TypeError: __init__() got multiple values for
> keyword argument 'empty_label'
>
> `field_name =

> forms.ModelMultipleChoiceField(queryset=MyModel.objects.all(),
> empty_label="Select something" )`

New description:

In a django form, when I set a value for the `empty_label` parameter, a
TypeError is raised. TypeError: __init__() got multiple values for keyword
argument 'empty_label'

`field_name =


forms.ModelMultipleChoiceField(queryset=MyModel.objects.all(),
empty_label="Select something")`

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32341#comment:2>

Django

unread,
Jan 11, 2021, 12:53:30 AM1/11/21
to django-...@googlegroups.com
#32341: forms.ModelMultipleChoiceField raising TypeError when empty_label provided
-------------------------------------+-------------------------------------
Reporter: thewamz | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 3.1
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
ModelMultipleChoiceField | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* ui_ux: 1 => 0
* resolution: => invalid
* severity: Release blocker => Normal


Comment:

`ModelMultipleChoiceField` doesn't support `empty_label` (see
[https://docs.djangoproject.com/en/3.1/ref/forms/fields/#django.forms.ModelMultipleChoiceField
docs]).

--
Ticket URL: <https://code.djangoproject.com/ticket/32341#comment:3>

Django

unread,
Jan 11, 2021, 12:54:58 AM1/11/21
to django-...@googlegroups.com
#32341: forms.ModelMultipleChoiceField raises TypeError with empty_label argument.

-------------------------------------+-------------------------------------
Reporter: thewamz | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 3.1

Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
ModelMultipleChoiceField | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/32341#comment:4>

Django

unread,
Aug 9, 2021, 12:17:00 PM8/9/21
to django-...@googlegroups.com
#32341: forms.ModelMultipleChoiceField raises TypeError with empty_label argument.
-------------------------------------+-------------------------------------
Reporter: thewamz | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 3.1
Severity: Normal | Resolution:

Keywords: | Triage Stage:
ModelMultipleChoiceField | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by piscvau):

* status: closed => new
* resolution: invalid =>


Comment:

Hello
In version 3.8 of module forms line 1315 , The class
ModelMultipleChoiceField.__init__ calls super().__init__ with empty_label
= None. This a real bug easy to correct.

--
Ticket URL: <https://code.djangoproject.com/ticket/32341#comment:5>

Django

unread,
Aug 9, 2021, 1:18:20 PM8/9/21
to django-...@googlegroups.com
#32341: forms.ModelMultipleChoiceField raises TypeError with empty_label argument.
-------------------------------------+-------------------------------------
Reporter: thewamz | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 3.1
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
ModelMultipleChoiceField | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed

* resolution: => invalid


Comment:

Please don't reopen closed ticket. This is not a bug,


`ModelMultipleChoiceField` doesn't support `empty_label` (see
[https://docs.djangoproject.com/en/3.1/ref/forms/fields/#django.forms.ModelMultipleChoiceField
docs]).

--
Ticket URL: <https://code.djangoproject.com/ticket/32341#comment:6>

Reply all
Reply to author
Forward
0 new messages