解決済み: 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 は、データベースの内容をテキスト ファイルにダンプするためのコマンド ライン ツールです。

Django でマイグレーションを行う方法

1.8

Django 1.8 でデータを移行するには、いくつかの方法があります。

1. migrate コマンドを使用して、開発サーバーで一連の移行を実行します。

$ python manage.py 移行

2. django-migrate ツールを使用します。

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

関連記事:

コメント