我想从表单中删除password1字段。但这并不排除。甚至我也不想删除密码字段,只是想从表单中禁用。
Forms.py
{
"pubA":"",
"pubB":"",
"pubC":"",
"ipA":{
"aA":{
"a":"",
"b":"",
"c":""
},
"aB":{
"a":"",
"b":"",
"c":""
},
"aC":{
"a":"",
"b":"",
"c":""
}
......
},
"ipB":{
"bA":{
"a":"",
"b":"",
"c":""
},
"bB":{
"a":"",
"b":"",
"c":""
},
"bC":{
"a":"",
"b":"",
"c":""
}
......
}
}
答案 0 :(得分:1)
在UserRegisterForm
new_user = f.save(commit=True)
new_user.password = new_user.set_password('sdfasd')
和forms.py
class UserRegisterForm(ModelForm):
class Meta:
model = User
fields = ('first_name', 'last_name', 'email', )