I’ve had trouble with dumping and loading data using the management commands dumpdata
and loaddata
, which I determined to be caused by non-ascii characters in the fields’ values.
After following into the rabbit hole of Django source code, I’ve found that:
- in
django/django/core/management/commands/dumpdata.py
(from line 228 on), no explicit encoding is set to the output file. - in line 32 of
django/django/core/serializers/json.py
there isself.json_kwargs.setdefault("ensure_ascii", False)
Therefore, I suspect some conflict between encodings of the fields’ string values and that used to write the file.
So, is it possible to enforce utf-8
on the output file or, alternatively, ascii
on the json markup?