我正在使用
以下是我的代码:
django-userena
。我有一个名为UserProfile
的模型。我在注册表单中添加了额外的字段。这些字段正确显示,但数据没有保存。我想将一些字段数据保存到另一个模型(Business
)中。例如,我有两个字段,如contact
和business
。我希望联系人字段将转到UserProfile
模型,而business
字段将转到Business Model
。有什么线索吗?谢谢以下是我的代码:
class SignupFormExtra(SignupForm):
address = forms.CharField(label=_(u'Address'),max_length=30,required=False)
contact = forms.CharField(label=_(u'Contact'),max_length=30,required=False)
business = forms.CharField(label=_(u'Business Name'),max_length=30,required=False)
def save(self):
"""
Override the save method to save the first and last name to the user
field.
"""
user_profile = super(SignupFormExtra, self).save(commit=False)
user_profile.address = self.cleaned_data['address']
user_profile.contact = self.cleaned_data['contact']
user_profile.business = self.cleaned_data['business']
user_profile.save()
return user_profile
更新:我正在将这些值存储在用户实例上... 我想将它们存储在Profile模型上--一个绑定到用户的实例。