Getting __init__() got an unexpected keyword argument 'instance' with CreateView of Django
I suspect class UserForm
should be model form. You may want to change fields, but it should be derived from `ModelForm.
So change form definition to
class UserForm(forms.ModelForm):
class Meta:
model = User
fields = [...] # list of fields you want from model
#or define fields that you want.
....
I override __init__() method incorrectly, without initial arguments, as show below
class MyForm(forms.ModelForm):
...
def __init__(self):
super(CaseForm, self).__init__()
...
And get this error as result
TypeError at /case/create
__init__() got an unexpected keyword argument 'initial'
To fix it, I set arguments to __init__() and pass them when call super class __init__(), see result below
class MyForm(forms.ModelForm):
...
def __init__(self, *args, **kwargs):
super(CaseForm, self).__init__(*args, **kwargs)
...