Create registration form for extended User model in Django 1.8

别说谁变了你拦得住时间么 提交于 2019-12-24 00:53:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!