हल: 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>

डंप क्या है

डंप डेटाबेस की सामग्री को टेक्स्ट फ़ाइल में डंप करने के लिए एक कमांड लाइन टूल है।

Django में माइग्रेशन करने के लिए नहीं

1.8

Django 1.8 में आपके डेटा को माइग्रेट करने के कुछ अलग तरीके हैं।

1. अपने विकास सर्वर पर माइग्रेशन की एक श्रृंखला चलाने के लिए माइग्रेट कमांड का प्रयोग करें:

$ python manage.py माइग्रेट

2. django-migrate टूल का उपयोग करें:

$ पिप django-migrate स्थापित करें $ cd myproject $ django-migrate init $ python manage.py माइग्रेट करें

संबंधित पोस्ट:

एक टिप्पणी छोड़ दो