[英]Django Auth User Model Set different field name for password
I recently look into Django framework and plan to migrate my old system into it. 我最近研究了Django框架,并计划将我的旧系统迁移到其中。 Therefore, there is legacy mysql database that I need to follow.
因此,有一个我需要遵循的旧版mysql数据库。 Is there anyway to change the field name of password of Django User Model?
无论如何,要更改Django用户模型的密码的字段名称吗? such as "pwd" or "password2".
例如“ pwd”或“ password2”。
I got research the Django document, only able to find out changing the username field https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#django.contrib.auth.models.CustomUser.USERNAME_FIELD 我研究了Django文档,仅能找出更改用户名字段https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#django.contrib.auth.models.CustomUser.USERNAME_FIELD
I think you can create a new class that inherits from user model and set the password field to be whatever you like. 我认为您可以创建一个从用户模型继承的新类,并将password字段设置为您喜欢的任何类型。
Something like: 就像是:
class MyUser(AbstractBaseUser):
...
password = models.CharField(max_length=100, db_column='custom_name')
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.