[Django]-Django forms error 'got multiple values for keyword argument 'choices''

7👍

✅

http://code.djangoproject.com/browser/django/trunk/django/forms/fields.py#L647

647     def __init__(self, choices=(), required=True, widget=None, label=None,
648                  initial=None, help_text=None, *args, **kwargs):
649         super(ChoiceField, self).__init__(required=required, widget=widget, label=label,
650                                         initial=initial, help_text=help_text, *args, **kwargs)

use:

species = f.ChoiceField(label='Species', choices=Specimen.SPECIES)
tests = f.MultipleChoiceField(label='Test', choices=Test.TESTS, widget=f.CheckboxSelectMultiple())

and:

sample_type = f.ChoiceField(label='Type of sample', choices=TYPE_CHOICES)

This is assuming that your choices are valid. Not sure what Specimen.SPECIES and Test.TESTS are. Those should be iterable of two-tuples according to:

ChoiceField.choices

An iterable (e.g., a list or tuple) of
2-tuples to use as choices for this
field. This argument accepts the same
formats as the choices argument to a
model field. See the model field
reference documentation on choices for
more details.

Leave a comment