1

I'm using django 1.8 in my project and it seems like the auth models are not being created. I have applied the auth migrations and I get;

python manage.py migrate --database=default auth
Operations to perform:
  Apply all migrations: auth
Running migrations:
  Rendering model states... DONE
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK

But only the django_content_type table is created. Am also using Postgres. Can anyone please give me pointers on how I can solve this. Thank you.

edit: running ;

python manage.py  createsuper 

part of error dump

django.db.utils.ProgrammingError: relation "auth_user" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...

Edit

settings.py 
....
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'myapp',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)
 ........

DATABASES = {
    'default': {
        'NAME': 'dbname',
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'USER': 'theuser',
        'PASSWORD': 'thepassword',
        'HOST':'thehost'
    },
    'auth_db': {
        'NAME': 'dbname',
       'ENGINE': 'django.db.backends.mysql',
        'USER': 'otheruser',
        'PASSWORD': 'thepassword',
        'HOST':'thehost'
    }
}
....

Am using 2 database connections where the mysql database is used to authenticate existing users. The idea is to use already existing users on the mysql database on the new application.

5
  • Applying auth.0001_initial... OK this tells me the auth table is created. Or do you mean it doesn't exist in the database itself? Have you tried creating a user? Commented Sep 11, 2015 at 10:19
  • Trying to create a user leads to an error see my edit. Commented Sep 11, 2015 at 10:54
  • try "python manage.py createsuperuser" Commented Sep 11, 2015 at 10:57
  • is your "django.contrib.auth" in INSTALLED_APP commented? Commented Sep 11, 2015 at 10:59
  • please see my edit above on the settings.py config thanks Commented Sep 11, 2015 at 11:08

2 Answers 2

2

Try migrating your auth app manually followed by default migrate command.

python manage.py migrate auth
python manage.py migrate

hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

I still get the same Applying auth.0001_initial... OK but the table is not created in the database.
0

I have solved the problem finally by removing the db routers. This is because in my application as described above, i'm routing the auth requests to another db where there are already existing.

Such that running

python manage.py sqlmigrate auth 000_initial

Produces and empty sql statement. Removing the db routers from the settings config proceeded by running

python manage.py migrate auth

produces the 'sql statements' hence migration of downstream apps proceeds without a problem.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.