נפתרה: django dump העברות קודמות

הבעיה העיקרית היא שאם תשליך העברה ואז תנסה להפעיל את ההגירות שוב, 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 הוא כלי שורת פקודה לשליפת תוכן מסד נתונים לקובץ טקסט.

מה לעשות הגירות בג'נגו

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

הודעות קשורות:

השאירו תגובה