简体   繁体   English

如何在Django中创建新用户时添加选项以添加更多字段

[英]How can I add an option to add more fields while creating a new user in django

在这里输入图片说明,我遵循的是django的官方文档,我需要能够在管理站点中添加选项的帮助,在这里我可以添加选项以添加新字段,例如客户名称和密码以及ID,因此如何我可以在页面本身上添加ID选项吗?

The easy way is create other class like CustomAdmin and use OnetoOne realation. 简单的方法是创建其他类(如CustomAdmin)并使用OnetoOne实现。

For example: 例如:

class CustomAdmin(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE,  blank=True, null=True, related_name='user_customUser')
username = models.CharField(max_length=100, null=True, blank=True, verbose_name='Username')
web_custom = models.CharField(max_length=100, null=True, blank=True, verbose_name='Web')
phone_custom = models.BigIntegerField(null=True, blank=True, verbose_name='Phone')

暂无
暂无

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

相关问题 使用带 Angular 和 Django 的 Stripe 创建新用户时,如何添加其他公司字段? - How can I add additional company fields when creating a new user using Stripe with Angular and Django? 如何在已经开发的 Django 用户表数据库上添加更多表字段 - How can i add more table fields on already developed Django User table Database 如何为用户可以选择添加更多字段的表单创建 Django model? - How can I create a Django model for a form in which users can choose to add more fields? 如何在使用 Django 表单创建注册表单时添加自定义字段? - How can I add custom fields when creating a sign up form using Django form? 如何扩展用户模型以向其中添加更多字段 - How to extend the user model to add more fields to it 我可以删除现有字段或在 Django 的默认用户数据库中添加更多字段吗?我还可以使用 email 而不是用户名登录吗? - Can I remove existing fields or add some more fields in the default User DB in Django?, Also can i login using email instead of username? 我如何使用Django将其他模型字段添加到默认auth_user模型 - How can i add extra model fields to default auth_user model using django 如何直接向Django ImageField添加额外选项? - How can I add extra option to Django ImageField directly? 如何为继承的tkinter Frame类添加新选项? - How can I add a new option to an inherited tkinter Frame class? 如何在 django 的用户模型中添加自定义字段? - How to add Custom fields in User model in django?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM