django 1.5.1
我创建自定义身份验证模型:
文件 api/models.py
from django.contrib.auth.models import BaseUserManager, AbstractUser
class User(AbstractUser):
token = models.CharField(max_length=64, null=False, blank=False, help_text=_('Photo for carte'), unique=True)
updated_token = models.DateTimeField(auto_now_add=True, help_text=_('Create record'))
USERNAME_FIELD = 'email'
objects = MyUserManager()
def __unicode__(self):
return "пользователь: %s" % self.email
class Meta:
app_label = 'custom_auth'
文件设置.py
AUTH_USER_MODEL = 'custom_auth.User'
.....
INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'api',
.....
'south',
'django.contrib.admin',
)
在 ./manage.py syncdb 我得到一个错误:
admin.logentry: 'user' has a relation with model <class 'api.models.User'>, which has either not been installed or is abstract.
如何决定这个问题?
编辑 1 尝试注释行并制作 syncdb:
'django.contrib.admin',
尝试在 ./manage.py shell 中创建用户后,syncdb 成功
In [1]: from api.models import User
In [2]: User.objects.create_superuser('test@test.com', 'test')
并收到错误:
DatabaseError: (1146, "Table 'app_name.custom_auth_user' doesn't exist")