Django Migratons: What is the best default way to dump and load data in DB apart from using third party app?

I'm new to Django and interested in knowing in-depth about migrations so I don't want to use the third-party apps(ex. flyway..)

I want to know how to dump hundreds of data in my Postgres DB without using 3rd party applications.

You can directly use postgresql tools:

there is a feature called fixtures which you can use: this is an example of dumping data

django-admin dumpdata [app_label[.ModelName] [app_label[.ModelName] ...]]

This is what I have tried to migrate my database from db.sqlite3 to PostgreSQL.

  1. Dump data in the data.json file.

    python dumpdata > data.json

  2. Edit the file of your project and change the database settings. (In my case I have used Heroku's PostgreSQL. You can get all the necessary details from the respective database providers (AWS, Heroku, etc).

'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': ' ', 
'USER':' ', 
'PASSWORD':' ’, 
'HOST':' ',
  1. python migrate --run-syncdb

  2. python loaddata data.json

If errors are encountered:

JSON parsing error:

Make sure the data.json file is saved with utf-16 LE encoding (guessed by VS Code).

Go to:



 stream_or_string = stream_or_string.decode()


 stream_or_string = stream_or_string.decode('UTF-16')
Back to Top