Đã giải quyết: django kết xuất các lần di chuyển trước đó

Vấn đề chính là nếu bạn kết xuất di chuyển và sau đó thử chạy lại di chuyển, django sẽ không nhận ra những thay đổi bạn đã thực hiện và thay vào đó sẽ chạy lại di chuyển ban đầu.

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>

bãi rác là gì

Dump là một công cụ dòng lệnh để kết xuất nội dung của cơ sở dữ liệu vào một tệp văn bản.

Muốn thực hiện di chuyển ở Django

1.8

Có một số cách khác nhau để di chuyển dữ liệu của bạn trong Django 1.8.

1. Sử dụng lệnh di chuyển để chạy một loạt quá trình di chuyển trên máy chủ phát triển của bạn:

di chuyển $ python management.py

2. Sử dụng công cụ di chuyển django:

$ pip cài đặt django-di chuyển $ cd myproject $ django-di chuyển init $ python manage.py di chuyển

bài viết liên quan:

Để lại một bình luận