我创建了一个自定义用户应用程序。 我的自定义用户扩展了AbstractBaseUser ...
在我的设置文件中:
AUTH_USER_MODEL = 'custom_auth.CustomUser'
我的自定义用户:
class CustomUser(AbstractBaseUser, PermissionsMixin):
DEGREE_CHOICES = zip( range(1,34), range(1,34) )
class Meta:
verbose_name = "user"
email = models.EmailField(
verbose_name='email address',
max_length=255,
unique=True,
db_index=True,
)
poster = models.ImageField(upload_to='users/poster/', blank=True, null=True)
first_name = models.CharField(max_length=80)
last_name = models.CharField(max_length=100 )
chapter = models.CharField(max_length=100 )
lodge = models.CharField(max_length=100 )
degree = models.IntegerField(max_length=2, choices=DEGREE_CHOICES )
country = models.CharField(max_length=100, blank=True, null=True)
is_staff = models.BooleanField(_('staff status'), default=False,
help_text=_('Designates whether the user can log into this admin '
'site.'))
is_active = models.BooleanField(_('active'), default=True,
help_text=_('Designates whether this user should be treated as '
'active. Unselect this instead of deleting accounts.'))
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
objects = CustomUserManager()
USERNAME_FIELD = 'email'
#REQUIRED_FIELDS = ['user_name' ]
现在我正在更改custom_auth的models.py上的很多字段并尝试迁移它。 我已更改的字段不会在数据库中更改,但会在数据库中添加新添加的字段。
如何正确迁移自定义用户?我做错了吗?