使用Djangocustomus在用户模型中添加其他字段

2024-10-02 18:22:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用这个代码https://github.com/jcugat/django-custom-user以电子邮件地址登录。不过,我希望添加联系电话,名字和姓氏的程序,它在扩展EmailUser模型下声明

我在model.py中的class下面添加了联系电话

class MyCustomEmailUser(AbstractEmailUser):
    """
    Example of an EmailUser with a new field date_of_birth
    """
    contact_number = models.CharField(blank=False,max_length=10)

我在admin.py中将MyCustomEmailUserAdmin类留空

class MyCustomEmailUserAdmin(EmailUserAdmin):
    """
    You can customize the interface of your model here.
    """
    pass

当我登录到管理面板,在用户下,我只看到电子邮件地址,输入密码和重新输入密码的形式添加用户。我看不到有联系电话,你知道我该怎么办吗


Tags: of代码用户pyhttpsgithubcom密码