已解決:django 轉儲以前的遷移

主要問題是,如果您轉儲遷移然後嘗試再次運行遷移,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 &gt; 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 &gt; 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 管理.py 遷移

2.使用django-migrate工具:

$ pip 安裝 django-migrate $ cd myproject $ django-migrate init $ python manage.py migrate

相關文章:

發表評論