主要问题是,如果您转储迁移然后尝试再次运行迁移,django 将无法识别您所做的更改,而是重新运行原始迁移。
I am trying to dump my previous migrations in Django. I have tried the following command: <code>python manage.py dumpdata --exclude contenttypes --exclude auth.permission > app/fixtures/initial_data.json</code> However, this only dumps my current data and not the data from my previous migrations. How can I do this? A: You can use <code>--format=json</code> to export your data into a json file and then you can use it as a fixture for your future migrations: <code>python manage.py dumpdata --format=json --indent=4 > app/fixtures/initial_data.json # add all your apps here separated by spaces </code>
什么是转储
Dump 是一个命令行工具,用于将数据库的内容转储到文本文件中。
Wot 在 Django 中进行迁移
1.8
在 Django 1.8 中迁移数据有几种不同的方法。
1. 使用 migrate 命令在您的开发服务器上运行一系列迁移:
$ python manage.py 迁移
2.使用django-migrate工具:
$ pip 安装 django-migrate $ cd myproject $ django-migrate init $ python manage.py migrate