5
votes

I can't find solution for the TypeError: init() takes 1 positional argument but 2 were given

TypeError appears when I try to make migrations in ubuntu concole. error:

  File "/home/wojciech/workspace/conference_room/conference_room/conference/forms.py", line 8, in NewRoomForm
    taken = forms.ChoiceField(TAKEN, label='Taken', widget=forms.Select)
TypeError: __init__() takes 1 positional argument but 2 were given

forms:

from django import forms
from .models import TAKEN


class NewRoomForm(forms.Form):
    name = forms.CharField(label='Name', max_length=32)
    number = forms.IntegerField(label='Room Number')
    taken = forms.ChoiceField(TAKEN, label='Taken', widget=forms.Select)
    description = forms.CharField(label='Description', widget=forms.Textarea)

models:

TAKEN = (
    (True, 'Yes'),
    (False, 'No')
)


class Room(models.Model):
    name = models.CharField(max_length=32)
    number = models.IntegerField()
    taken = models.BooleanField(choices=TAKEN)
    description = models.CharField(max_length=128)

Any ideas how to fix it?

1

1 Answers

5
votes
taken = forms.ChoiceField(choices=TAKEN, label='Taken', widget=forms.Select)

you need to put the choices in the choices key