2024-04-25 17:31:20 发布
网友
如何在注册表中添加新字段? 我很难找到答案,所以我在这里分享
在表单.py公司名称:
from registration.forms import RegistrationForm class UserProfileRegistrationForm(RegistrationForm): first_name = forms.CharField(max_length=15, label='First name') last_name = forms.CharField(max_length=15, label='Last name') date_of_birth = forms.DateField(label='Date of birth', widget=SelectDateWidget(years=[y for y in range(1950, datetime.datetime.now().year-17)], attrs=({'style': 'width: 33%; display: inline-block;'})),) class Meta: model = UserModel() fields = (UsernameField(), "email", 'first_name', 'last_name', 'date_of_birth')
在视图.py在
注意:如果您希望用户自动登录,请使用:https://djangosnippets.org/snippets/1547/
在网址.py在
from myapp.views import UserProfileRegistration url(r'^accounts/register/$', UserProfileRegistration.as_view(), name='registration_register'), url(r'^accounts/', include('registration.backends.simple.urls')),
谢谢杰基尔德医生。 参考号:https://github.com/macropin/django-registration/issues/73
在表单.py公司名称:
在视图.py在
^{pr2}$注意:如果您希望用户自动登录,请使用:https://djangosnippets.org/snippets/1547/
在网址.py在
谢谢杰基尔德医生。 参考号:https://github.com/macropin/django-registration/issues/73
相关问题 更多 >
编程相关推荐