2

我正在创建一个注册表单,以便用户可以注册。

模型.py

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    address = models.CharField(max_length=100)

我不确定forms.py和views.py中应该包含什么,因为地址不是用户的一部分,而是UserProfile(UserProfile的扩展)

我希望能够在 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')
4

0 回答 0