Django's manage.py dumpdata adds free text to each file

I am trying to move Django data from SQLite to Postgres, following this flow:

SQLite connection in settings.py
manage.py dumpdata > data.json
Postgres connection in settings.py
manage.py loaddata data.json

It seems to be sort of working (still struggling with "matching query does not exist" errors), but one thing definitely looks like a bug: The data.json file always starts with a free-text line "Tracking file by folder pattern: migrations". Then follows the JSON content. As the result, the command loaddata gives the to be expected error:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

It all works fine if open the JSON file in a text editor and delete that first line. It also makes sense that the line is there, since dumpdata without > data.json outputs "Tracking file by folder pattern: migrations" before the data. Is there a way to prevent Django from writing that line to the file?

use dumpdata -o file to specifiy the output file, the output file will just contain the data.

python manage.py dumpdata -o data.json
Вернуться на верх