Errors when I try to migrate in Django2

前端 未结 3 1450
挽巷
挽巷 2020-12-10 21:04

I have a problem (at least I think). I am new in all this, so I apologize If I ask something stupid. I have some site, which is working normally. When I try to make migrati

相关标签:
3条回答
  • 2020-12-10 21:21

    First, you must remove migration folders in each app

    then, you can use migration commands

    python manage.py makemigrations
    python manage.py migrate
    
    0 讨论(0)
  • 2020-12-10 21:23

    I had the same problem with postgresql-server-9.2.24-1.el7_5.x86_64 that is installing in Centos 7 by default. Installing Postgresql 11 solved the problem.

    0 讨论(0)
  • 2020-12-10 21:39

    Whenever you are adding any new field and facing migrate error.

    Kindly follow these steps:

    • Delete all migration files(not the migration folder, keep the init.py file
    • Truncate the _django_migrations_ table
    • comment the new field which is to be added from the models.py. (Do make sure this step otherwise django will throw error when you would follow the below steps)
    • run python manage.py makemigrations
    • run python manage.py migrate --fake
    • Uncomment the new field to be added
    • run python manage.py makemigrations
    • run python manage.py migrate

    Generally these steps solve any kind of migration problem.

    P.S. : When you face problem in only one app, I would recommend to delete entries of that particular app from the django_migrations table

    0 讨论(0)
提交回复
热议问题