问题
I am creating a registration form so users can sign-up.
models.py
class UserProfile(models.Model):
user = models.OneToOneField(User)
address = models.CharField(max_length=100)
I'm not sure what should go in the forms.py and views.py since address isn't part of user but of UserProfile (an extension of UserProfile)
I want to be able to do something like this in forms.py:
email = forms.EmailField(label='Your Email')
username = forms.CharField(label='Your Username')
password1 = forms.CharField(label='Password', \
widget=forms.PasswordInput())
password2 = forms.CharField(label='Password Confirmation', \
widget=forms.PasswordInput())
first_name = forms.CharField(label='First Name')
last_name = forms.CharField(label='Last Name')
address = forms.CharField(label='Your Address')
来源:https://stackoverflow.com/questions/34050266/create-registration-form-for-extended-user-model-in-django-1-8