django 1.9: ProgrammingError: relation “users_user” does not exist

后端 未结 3 2060
忘掉有多难
忘掉有多难 2021-02-08 01:31

I am running into a ProgrammingError when doing migrate, I think it may be related to the use of django-allauth with a custom user. Here is what I do

1/ Create a fresh d

相关标签:
3条回答
  • 2021-02-08 02:16

    FYI-

    I had this problem, and to resolve it I had to comment out all references to views.py in my urls.py and url_tenants.py files. Then, I ran makemigrations and got the database tables to create, then run migrate_schemas, and later uncomment the url files. Hope this helps someone.

    0 讨论(0)
  • 2021-02-08 02:21

    Your error is caused by the order you run the migrations. Since many apps depend on the user model existing, you must run the initial migrations for your custom user app before those other apps.

    If you change the default user model in an existing project, it might be easier to discard all existing migrations (and the database) and rebuild from scratch. The order to apply migrations would be:

    1. The core django.contrib apps.
    2. Your custom user app.
    3. Other custom apps and third party apps.

    You can use django-admin showmigrations to see which migrations exists and are planned.

    0 讨论(0)
  • 2021-02-08 02:22

    You have to delete the migrations folder and then, you should do

    python manage.py migrate --run-syncdb
    
    python manage.py migrate --fake appname
    
    0 讨论(0)
提交回复
热议问题