简体   繁体   English

如何在 django 的用户模型中添加自定义字段?

[英]How to add Custom fields in User model in django?

我正在创建一个网站,在该网站上我需要用户在注册网站时提供额外信息,例如(他有没有电脑,是否订阅了时事通讯,电子邮件,电话号码和密码确认)注意:有没有办法让我可以使反应开发人员可以使用此模型吗?

You can find a good example how to extend the User object in the django documentation: https://docs.djangoproject.com/en/4.0/topics/auth/customizing/#extending-the-existing-user-model您可以在 django 文档中找到如何扩展User对象的一个​​很好的示例: https ://docs.djangoproject.com/en/4.0/topics/auth/customizing/#extending-the-existing-user-model

If there is the need to completly replace the User model, there is a django way to do this as well: https://docs.djangoproject.com/en/4.0/topics/auth/customizing/#substituting-a-custom-user-model如果需要完全替换User模型,还有一种 django 方法可以做到这一点: https ://docs.djangoproject.com/en/4.0/topics/auth/customizing/#substituting-a-custom- 用户模型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM