我想要一个更大的auth_user
表,包括2-3个额外的字段。你知道吗
问题是下面的代码正在创建一个新的,与auth\u user one完全相同,但没有替换它。你知道吗
设置.py
AUTH_PROFILE_MODULE = "myaccount.MyUser"
型号.py
from django.contrib.auth.models import AbstractUser
class MyUser(AbstractUser):
gender = models.DateField()
location = models.CharField(max_length=30)
birthday = models.CharField(max_length=30)
而不是创建一个名为myaccount_MyUser
的新表。如何替换当前的auth_user
表而不是创建新表?你知道吗
我想你必须
在你的型号.py在获得用
AbstractUser
扩展的方法之前。应该可以的我没有尝试也不推荐的一种黑客方式是在模型中指定表名:
我建议使用新表并使用south datamigration从旧表迁移数据。下面是如何做到这一点的详细答案:
Migrating existing auth.User data to new Django 1.5 custom user model?
我相信这个可以帮助你:
https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-user
相关问题 更多 >
编程相关推荐