해결됨: 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 도구를 사용합니다.

$ pip 설치 django-migrate $ cd myproject $ django-migrate 초기화 $ python manage.py 마이그레이션

관련 게시물:

코멘트 남김