我正在使用带有 django 1.5 的自定义用户模型,但是当我尝试执行初始 syncdb 或访问 shell 时,我收到以下错误:ImproperlyConfigured: AUTH_USER_MODEL refers to model tfe.CustomUser not installed
. 但是,它在 settings.py 文件中列出,所以我不知道为什么会发生这种情况。
#models.py CustomUser
class CustomUser(AbstractBaseUser, PermissionsMixin):
username = models.CharField(
verbose_name = 'Username',
max_length = 40,
unique = True,
db_index = True,
)
email = models.EmailField(max_length=254, unique=True, verbose_name='email')
nation_id = models.IntegerField()
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
gender = models.CharField(max_length=10, null=True, blank=True, choices=GENDER_CHOICES)
date_of_birth = models.DateField(null=True, blank=True, help_text="Use 'yyyy-mm-dd' format")
date_joined = models.DateTimeField(default=timezone.now())
website = models.URLField(max_length=1000, null=True, blank=True)
USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ['email','nation_id',]
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
is_staff = models.BooleanField(default=False)
objects = CustomUserManager()
def get_full_name(self):
return self.email
def get_short_name(self):
return self.username
def __unicode__(self):
return self.username
#settings.py
AUTH_USER_MODEL = 'tfe.CustomUser'