Django : Transfer data from Sqlite to another database

14th February, 2019

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 dumpdata > db.json
  2. Change the database settings to new database such as of MySQL / PostgreSQL.
  3. python migrate
  4. python shell 
    Enter the following in the shell
    from django.contrib.contenttypes.models import ContentType
  5. python loaddata db.json

Thats it .. and now your new database should have all the data from the Sqlite. Cheers !