Getting __init__() got an unexpected keyword argument 'instance' with CreateView of Django

后端 未结 4 1625
无人及你
无人及你 2020-12-10 10:01

Some details:

Request Method: GET
Request URL: http://localhost:8080/user/create
Django Version: 1.5.1
Exception Type: TypeError
Exception Value: ____init__         


        
4条回答
  •  北海茫月
    2020-12-10 10:42

    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.
       ....
    

提交回复
热议问题