Create registration form for extended User model i

2019-07-08 02:27发布

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')

0条回答
登录 后发表回答