当我进入管理界面时,所有字段都在那里,但在提交表单后,除了用户名和电子邮件之外,没有任何数据。有什么帮助吗?
class SignupFormExtra(userena.forms.SignupForm):
first_name = forms.CharField(max_length=20)
last_name = forms.CharField(max_length=20, required=False)
gender = forms.CharField(max_length=3, required=False)
phone = forms.CharField(label=(u'Phone Number'),max_length=10, required=False)
cell = forms.CharField(label=(u'Cell Number'),max_length=10)
address = forms.CharField(label=(u'Dental Practice Address'),max_length=50, required=False)
def save(self):
self.cleaned_data['username'] = self.cleaned_data['email']
user = super(SignupFormExtra, self).save()
user.first_name = self.cleaned_data['first_name']
user.last_name = self.cleaned_data['last_name']
#user.birth_date = self.cleaned_data['birth_date']
user.gender = self.cleaned_data['gender']
user.phone = self.cleaned_data['phone']
user.cell = self.cleaned_data['cell']
user.address = self.cleaned_data['address']
user.save()
return user
答案 0 :(得分:1)
SignupForm.save
会返回contrib.auth.User
个对象,该对象没有gender
,phone
,cell
或address
个字段。我的猜测是这些都在你的个人资料模型上,但在你所显示的代码中,这不是你试图保存它们的地方。
答案 1 :(得分:0)
问题出在你的models.py模块中,而不是表格中。
答案 2 :(得分:0)
userena.forms.SignupForm创建一个UserenaSignup,该模型没有您指定的字段。
请参阅:https://github.com/bread-and-pepper/django-userena/blob/master/userena/models.py#L39