Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Revisions

3 of 4
added 3 characters in body
Elena Kr
  • 171
  • 1
  • 1
  • 5

Python: Can dumpdata cannot loaddata back. UnicodeDecodeError

I am using Python 2.7 , django1.5 and POstgreSQL 9.2 for two weeks. Never saw it before. Everything is freshly installed on my Win7 so it should have default settings. Djungo beautifully generates tables in my db. Looks like everything works fine. I am able to dump data from my database by

manage.py dumpdata > test.json

or

manage.py dumpdata --indent4 > test.json

I saw the json file it looks as it should.

then I truncate some tables and try to load them from JSON file

python manage.py loaddata database = T2 test.json // or without db name

I got

"UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: invalid start byte"

It I open the test.json file by notepad and save it as utf8 and try again then I have

"No JSON object could be decoded"

The file still looks OK, not empty.

By the way when I open the json file by notepad it offers me to save it as Unicode. My database has UTF8 encoding. Please advice. Thank you.

Elena Kr
  • 171
  • 1
  • 1
  • 5
default

AltStyle によって変換されたページ (->オリジナル) /