Admin.logentry: "user" refers to the <class 'api.models.User'> model, which is either not installed or is abstract
django 1.5.1
I create a custom auth model:
file 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' settings.py file
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', )
on./manage.py syncdb I get an error message:
admin.logentry: 'user' has a relation with model <class 'api.models.User'>, which has either not been installed or is abstract. How to solve this problem?
Edit 1 tried the comment line and did syncdb:
'django.contrib.admin', syncdb was successful after that, try creating a user in the shell. /manage.py
In [1]: from api.models import User In [2]: User.objects.create_superuser(' test@test.com ', 'test') and get the error:
DatabaseError: (1146, "Table 'app_name.custom_auth_user' doesn't exist") You will need to set app_label in your class, which is also in your INSTALLED_APPS : either set app_label = 'api' (by default) or add 'custom_auth' to your INSTALLED_APPS (of course, this is necessary to be a valid application).
The validation process in Django tries to get a new user class using get_model , and by default get_model returns models only for installed applications. You can confirm your current code:
>>> loading.get_model('custom_auth', 'user') >>> loading.get_model('custom_auth', 'user', only_installed=False) > api.models.User