gmocamilotd
10/27/2019 - 11:48 PM

Django : Transfer data from Sqlite to another database

Whenever a person starts learning Django, she/he starts from Sqlite database. And by the time you know most of the Django, you realize that that your most important data is in the Sqlite and now you would want to use high end databases like PostgreSQL or MySQL.

In order to achieve that, do the following steps in order :

  1. python manage.py dumpdata > db.json
  2. Change the database settings to new database such as of MySQL / PostgreSQL.
  3. python manage.py migrate
  4. python manage.py shell
  5. Enter the following in the shell
from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()
python manage.py loaddata db.json