我伸出RegistrationFormUniqueEmail
無法添加自定義字段到Django的註冊
class CustomRegistrationFormUniqueEmail(RegistrationFormUniqueEmail):
first_name = forms.CharField(label=_('First name'), max_length=30,required=True)
last_name = forms.CharField(label=_('Last name'), max_length=30, required=True)
def save(self, profile_callback=None):
new_user = super(CustomRegistrationFormUniqueEmail, self).save(profile_callback=profile_callback)
new_user.first_name = self.cleaned_data['first_name']
new_user.last_name = self.cleaned_data['last_name']
return new_user
然後改變視圖
# form = form_class(data=request.POST, files=request.FILES)
form = CustomRegistrationFormUniqueEmail(data=request.POST, files=request.FILES)
但是,我仍然看到其中只包含四個字段的默認格式。