我在Django上有一个项目。该项目具有MySQL上的现有数据库,该项目对我的模型,视图等进行了新更改。
当我尝试迁移时,它显示错误,但未在数据库中创建新更改。
我重置了迁移,然后重试,但是存在相同的问题。
我运行的突击队:
[root@server SistemaGestion]# find . -path "*/migrations/*.pyc" -delete
[root@server SistemaGestion]# python manage.py migrate
Operations to perform:
Apply all migrations: admin, contenttypes, auth, sessions
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
The following content types are stale and need to be deleted:
areas | subproceso
Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.
Type 'yes' to continue, or 'no' to cancel: yes
[root@server SistemaGestion]# python manage.py makemigrations
Migrations for 'procesos':
0001_initial.py:
- Create model Colaboradores
Migrations for 'indicadores':
0001_initial.py:
- Create model Objetivos
...
...
...
[root@server SistemaGestion]# python manage.py migrate
Operations to perform:
Apply all migrations: procesos, indicadores, seguridad, admin, sessions, auth, personal, contenttypes, auditoria, normas, documentos, sac, areas
Running migrations:
No migrations to apply.
答案 0 :(得分:0)
如果您的表已经存在,则应在进行迁移后运行python manage.py migrate --fake-initial
。请参阅Django文档中的详细信息... https://docs.djangoproject.com/en/2.1/topics/migrations/#adding-migrations-to-apps。