Changes between Initial Version and Version 1 of Ticket #32439
- Timestamp:
- Feb 12, 2021, 3:59:35 AM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #32439 – Description
initial v1 5 5 The reason for the error is, I think, described in https://stackoverflow.com/questions/64457733/django-dumpdata-fails-on-special-characters/65186947#65186947 with a "hacky" solution. I quote: 6 6 7 "To save json data in django the TextIOWrapper is used:7 "To save json data in django the TextIOWrapper is used: 8 8 9 9 The default encoding is now locale.getpreferredencoding(False) (...) 10 10 11 In documentation of locale.getpreferredencoding fuction we can read:11 In documentation of locale.getpreferredencoding fuction we can read: 12 12 13 13 Return the encoding used for text data, according to user preferences. User preferences are expressed differently on different systems, and might not be available programmatically on some systems, so this function only returns a guess. 14 14 15 Here I found "hacky" but working method to overwrite these settings:15 Here I found "hacky" but working method to overwrite these settings: 16 16 17 In file settings.py of your django project add these lines:17 In file settings.py of your django project add these lines: 18 18 19 import _locale20 _locale._getdefaultlocale = (lambda *args: ['en_US', 'utf8'])"19 import _locale 20 _locale._getdefaultlocale = (lambda *args: ['en_US', 'utf8'])" 21 21 22 22 In Python I can my "inspect _locale._getdefaultlocale" variable in my (Danish) Windows installation: