Getting a strange error when defining my django forms. I get the error:
__init__() got multiple values for keyword argument 'choices'
This happens with both TestForm and SpeciesForm (quoted below); basically both forms with the ‘choices’ keyword argument. init() is never explicitly called, and the forms aren’t even instantiated in the view yet. There’s one ModelForm and one plain Form.
from django import forms as f
from orders.models import *
class TestForm(f.Form):
species = f.ChoiceField('Species', choices=Specimen.SPECIES)
tests = f.MultipleChoiceField('Test', choices=Test.TESTS, widget=f.CheckboxSelectMultiple())
dna_extraction = f.CharField('DNA extraction', help_text='If sending pre-extracted DNA, we require at least 900 ng')
class SpeciesForm(f.ModelForm):
TYPE_CHOICES = (
('blood', 'Blood'),
('dna', 'Extracted DNA'),
)
dam_provided = f.BooleanField('DAM', help_text='Is dam for this specimen included in sample shipment?')
sample_type = f.ChoiceField('Type of sample', choices=TYPE_CHOICES)
dna_concentration = f.CharField('DNA concentration', help_text='If sending extracted DNA, approximate concentration')
class Meta:
exclude = ['order']
model = Specimen
Any help would be appreciated. Not sure why this is happening as the forms are pretty bare-bones.
http://code.djangoproject.com/browser/django/trunk/django/forms/fields.py#L647
use:
and:
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: