تم حل: 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 هي أداة سطر أوامر لتفريغ محتويات قاعدة البيانات إلى ملف نصي.

Wot لجعل الهجرات في Django

1.8

هناك عدة طرق مختلفة لترحيل بياناتك في Django 1.8.

1. استخدم الأمر migrate لتشغيل سلسلة من عمليات الترحيل على خادم التطوير الخاص بك:

ترحيل $ python management.py

2. استخدم أداة django-migrate:

تثبيت $ pip django-migrate $ cd myproject $ django-migrate init $ python manager.py ترحيل

الوظائف ذات الصلة:

اترك تعليق