Solucionat: django dump migracions anteriors

El problema principal és que si aboqueu una migració i després proveu de tornar a executar les migracions, django no reconeixerà els canvis que heu fet i tornarà a executar la migració original.

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>

Què és l'abocador

Dump és una eina de línia d'ordres per abocar el contingut d'una base de dades a un fitxer de text.

Què fer migracions a Django

1.8

Hi ha algunes maneres diferents de migrar les vostres dades a Django 1.8.

1. Utilitzeu l'ordre migrate per executar una sèrie de migracions al vostre servidor de desenvolupament:

$ python manage.py migrate

2. Utilitzeu l'eina django-migrate:

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

Articles Relacionats:

Deixa el teu comentari