I am trying to write a source JSON device that will load after every syncdb call.
I put the initial_data.json file in my mysite/myapp/fixtures :
[ { "model": "myapp.Person", "pk": 1, "fields": { "first_name": "Tom", "last_name": "Yam" } } ]
Everything works when the file is encoded in ASCII, but when I save it in UTF-8 encoding (I need to use characters other than ASCII), I get the following error:
Problem installing fixture 'initial_data.json': Traceback (most recent call last): File "D:\Tom\DjangoEnv\Lib\site-packages\django\core\management\commands\loaddata.py", line 190, in handle for obj in objects: File "D:\Tom\DjangoEnv\Lib\site-packages\django\core\serializers\json.py", line 47, in Deserializer raise DeserializationError(e) DeserializationError: No JSON object could be decoded
According to the Django documentation, I need to set ensure_ascii=False when working with non-ASCII data and JSON serializers, but I canβt how to do this (since it is called from the syncdb function.
Any ideas on how to use a UTF-8 encoded JASON file as a tool?
source share