Hello,

I believe Bugs in Django are to be reported in this user list. Below is a report for a bug which does not seem to be already filed.

In the documentation reference on the ModelMultipleChoiceField there is no restrictios mentioned on the empty_label attribute.

Whenever you declare an attribute empy_label for a ModelMultipleChoiceField, it generates an error during the system_checks

 typeError " __init__() got multiple values for keyword argument 'empty_label

To reproduce the bug : :

class MyForm(forms.Form):
    field = forms.ModelMultipleChoiceField(
        queryset = Imodelclass.objects.all(),)
        empty_label=('------------'))

Another user on stackoverflow encountered  this same problem see here : https://stackoverflow.com/questions/52263426/django-empty-label-for-modelmultiplechoicefield-multiple-values-for-keyword-arg

The cause of the error is the following :

the code ( see fdjango/forms/models.py line 1266 sets the empty_label attribute to None while calling the super_class (ModelChoiceField):

super().__init__(queryset, empty_label=None, **kwargs)

while the super_class.__init__ sets the empy_label to "---------".

removing the empty_label= None in the call to the super_class solved the problem for me.

best regards

Odile Lambert




--
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/063841b4-5b58-4931-6ea3-29188ccc8171%40laposte.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to