Вирішено: 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

Схожі повідомлення:

Залишити коментар