[Fixed]-Why do I get a "auth_user does not exist"error when running "migrate" on a newly created django project with "registration redux" app installed?

25๐Ÿ‘

After updating my Django version, I got this error and fix as running these two lines:

python manage.py migrate auth
python manage.py migrate

auth_user table inside auth model should run first I guess.

๐Ÿ‘คDeniz Kaplan

4๐Ÿ‘

The problem is avoided when you do as Pedro Wagner suggests (auth_user error with Django 1.8 and syncdb / migrate):

Make sure that for all your apps, there exist initial migrations files by running:

manage.py makemigrations my_app

Iโ€™d do it not only for those that depend on auth because I think the problem is more general.

The root cause for this behaviour seems to me that for some reason

manage.py makemigrations

does not always create the initial migrations if they are not already there, contrary to:

manage.py makemigrations my_app

Unfortunately I cannot fathom the reasons for this asymmetry.

๐Ÿ‘คYtsen de Boer

4๐Ÿ‘

I think you just forgot to migrate your auth models. However, to do that, just type in the following command on your terminal.

python manage.py migrate 

or

python manage.py migrate auth

Hope this settles your error in the program.

1๐Ÿ‘

I think you needed to run:

python manage.py syncdb

and potentially you need to setup some dependencies? Probably not necessary after syncdb.

South 1 style (Django < 1.7)

class Migration:

    depends_on = (
        ("accounts", "0001"),
    )

    def forwards(self):
        ....

South 2 style (Django >= 1.7)

from django.db import migrations, models

class Migration(migrations.Migration):

    dependencies = [("accounts", "0001")]
๐Ÿ‘คEric Carmichael

0๐Ÿ‘

Once you create a migration for your app it will automatically add the necessary dependencies. So in this case just run ./manage.py makemigrations registration.

Please check the registration/migrations/0001_initial.py file and you should see something like this:

dependencies = [
    migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

This means you need to create migrations for all your apps with any kind of dependency.

๐Ÿ‘คHassek

0๐Ÿ‘

I had this problem too, solved it by replacing old registration with one that includes pull #25:

pip install git+https://github.com/macropin/django-registration.git@v1.2c0

0๐Ÿ‘

In my case, this has been resolved re-adding some modules in INSTALLED_APPS that had been removed. As a consequence, some tables in the database were confusing the migration scheme and then ruining the test command because the default database was containing those previous migrations.

Fixed re-adding the modules, allauth and other related submodules in my case.

๐Ÿ‘คyomguy

-2๐Ÿ‘

you have not migrated your models

python manage.py makemigrations my_app_name

for mac os

python3 manage.py makemigrations my_app

๐Ÿ‘คpujan rai

Leave a comment