1

Getting the error

CommandError: One or more models did not validate:
admin.logentry: 'user' has a relation with model su.SuUser, which has either not been installed or is abstract.`

when I run python manage.py test.

su is my user app, and app is where most of the work is done.

settings.py

INSTALLED_APPS = (
    ...
    "su",
    "app",
)
AUTH_USER_MODEL = 'su.SuUser'

su/models.py

class SuUser(AbstractBaseUser, PermissionsMixin):
    username = models.CharField(_('User name'), max_length=254, unique=True, db_index=True)
    ...

    class Meta:
        app_label = 'su'

app/tests.py

from django_nose import FastFixtureTestCase as TestCase

from nose.tools import assert_equals

from django.contrib.auth import get_user_model
from django.test.utils import override_settings

User = get_user_model()

@override_settings(AUTH_USER_MODEL='su.SuUser')
class TestApp(TestCase):
    ...

Any idea? syncdb works fine. Running the app works fine.

EDIT 1

Even if I try to skip the custom user such as

@skipIfCustomUser
class TestApp(TestCase):
    ...

still getting the same errors.

Andrew Sledge
  • 10,163
  • 2
  • 29
  • 30

1 Answers1

0

I found a fix, but it may be a symptom of a bug. Previously, my directory structure looked like this:

root/
    su/
        su/
            views.py
            models.py (held SuUser)
            urls.py
            wsgi.py
            ...
        app/
            views.py
            models.py
            urls.py
            tests.py

on a whim, I broke out the user part into it's own app

root/
    su/
        su/
            views.py
            models.py
            urls.py
            wsgi.py
            ...
        suuser/
            views.py
            models.py (holds SuUser)
            urls.py
            ...
        app/
            views.py
            models.py
            urls.py
            tests.py

This works. After debugging, I found that the su "app" was never getting loaded into the app_store (django/db/models/loading.py). I haven't traced it back to see why or where or if it's by design. Anyone know?

Andrew Sledge
  • 10,163
  • 2
  • 29
  • 30