有两个模型组和学生,其中只有一个表,学生表被删除.
如何让Django重新创建已删除的表?如果我做makemigrations
,它会打印"未检测到任何更改".
在管理页面上,当我点击学生表时,它会抛出一个异常:
relation "students_students" does not exist
有两个模型组和学生,其中只有一个表,学生表被删除.
如何让Django重新创建已删除的表?如果我做makemigrations
,它会打印"未检测到任何更改".
在管理页面上,当我点击学生表时,它会抛出一个异常:
relation "students_students" does not exist
In django 1.7 you can try:
1. Delete your migrations folder
2. In the database: DELETE FROM django_migrations WHERE app = 'app_name'.
You could alternatively just truncate this table.
3. python manage.py makemigrations
4. python manage.py migrate --fake
If you are working in django 1.9.5 this is the 100 % solution for this problem:
1. Delete your migrations folder
2. In the database: DELETE FROM django_migrations WHERE app = 'app_name'.
You could alternatively just truncate this table.
3. python manage.py makemigrations app_name
4. python manage.py migrate
这对我来说100%有效!