我正在使用Django-redux,但注册表格仅接受用户名,电子邮件和密码。但是,我也想接受名字和姓氏以及其他模型(例如个人资料pic和city)中的字段。.我只能找到以下问题:将名字和姓氏添加到Django-Registration中,但未得到回答。
这是在我的urls.py中:
url(r'^', include('registration.backends.simple.urls')),
这是在我的模板中:
{{ form.as_p }}
我也想将此表格添加到注册表格中:
class UserProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ('profilepic', 'city')
谢谢你。
步骤1.在模型中添加您的字段(models.py)
firstname = models.CharField(max_length=255)
lastname = models.CharField(max_length=255)
步骤2.删除您的迁移文件夹并从数据库中删除表
第三步 使用make migration命令,然后迁移您的项目。
希望它能解决您的问题。
或者你用这个..
new_user = User.objects.create_user(username, email, password)
new_user.is_active = False
new_user.first_name = first_name
new_user.last_name = last_name
new_user.save()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句