My code:
views.py
class mySignupView(SignupView):
template_name = "accounts/signup.html"
forms.py
class MySignupForm(SignupForm):
first_name = forms.CharField(label=_('First name'), widget=forms.TextInput())
last_name = forms.CharField(label=_('Last name'), widget=forms.TextInput())
date_of_birth = forms.DateField(label=_('Date of Birth'), widget=forms.SelectDateWidget(years=range(1908, this_year+1), empty_label=("Choose Year", "Choose Month", "Choose Day"), attrs=({'style': 'width: 33%; display: inline-block;', 'class': 'form-select'})))
def save(self, request):
user = super(MySignupForm, self).save(request)
return user
class Meta:
model = User
fields = ('username', 'email','first_name', 'last_name', 'gender', 'date_of_birth', 'marital_status', 'info', 'city', 'state', 'region', 'zip_code', 'street_address', 'phone')
settings.py:
ACCOUNT_FORMS = {
'login': 'accounts.forms.LoginForm',
'signup': 'accounts.forms.MySignupForm',
'add_email': 'accounts.forms.AddEmailForm',
'change_password': 'accounts.forms.ChangePasswordForm',
'set_password': 'accounts.forms.SetPasswordForm',
'reset_password': 'accounts.forms.ResetPasswordForm',
'reset_password_from_key': 'accounts.forms.ResetPasswordKeyForm',
}
Come posso fare che prenda anche i campi :
class Meta:
model = User
fields = ('username', 'email','first_name', 'last_name', 'gender', 'date_of_birth', 'marital_status', 'info', 'city', 'state', 'region', 'zip_code', 'street_address', 'phone')
Avete un’idea come fare?
Grazie mille e scusate se parlo in italiano.
INFO: Translate “Italian to english”
Buona notte.