使用Django在用户注册时填写用户个人资料 [英] Fill user profile on user registration with Django

查看:90
本文介绍了使用Django在用户注册时填写用户个人资料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Django(和 django-registration-redux )提供的用户默认身份验证来开发应用程序.同样在docs中,他们建议将用户个人资料与其他模型中的 OneToOneField 链接,如下所示: https://docs.djangoproject.com/en/1.10/topics/auth/customizing/

I'm developing an application with the user default authentication provided by Django (and django-registration-redux). Also in docs, they recommend to link the user profile with a OneToOneField in a different model,as explain here: https://docs.djangoproject.com/en/1.10/topics/auth/customizing/

问题是:如何建立包括个人资料表格的注册视图?

请注意,它仅使用基本数据创建用户帐户,而没有个人资料信息.我已经在从 AbstractUser 继承并自定义用户模型的其他项目中工作,但这次我想使用Profile模型

Note that it's only creating a user account with the basic data without profile info. I already have worked in other project inheriting from AbstractUser and customizing User Model but I would like this time use Profile model

你能帮我吗?

推荐答案

问题是:如何建立包含以下内容的注册视图:个人资料表格?

The problem is: How to build a registration view that includes the profile form?

简短的答案是不要这样做.

The short answer is don't do this.

您可能自己已经注册了数百个站点.他们是否在注册时要求您提供此信息?不.因为它不是用户友好的.配置文件创建应与注册分开.

You've probably signed up on hundreds of sites yourself. Did they ask you for this information at registraion? nopes. Because it's not user fiendly. The profile creation should be separated from registration.

如果您确实想收集此信息,则需要用自己的表格替换默认的用户注册表格.AFAIK django-registration-redux中没有设置可以更改默认格式.因此,您还必须自定义视图.这么多辛苦的工作只是有所收获.

If you really want to gather this information you need to replace the default user registration form with your own. AFAIK there isn't a setting in django-registration-redux to change the default form. So you will have to customize the view as well. So a lot of hard work for a little gain.

请注意,它仅使用基本数据创建用户帐户没有个人资料信息

Note that it's only creating a user account with the basic data without profile info

这应该是应该的样子.

这篇关于使用Django在用户注册时填写用户个人资料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆