Changes between Version 1 and Version 2 of Ticket #32439
- Timestamp:
- Feb 12, 2021, 4:00:38 AM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #32439 – Description
v1 v2 4 4 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 '' 7 "To save json data in django the TextIOWrapper is used: 6 8 7 "To save json data in django the TextIOWrapper is used: 9 The default encoding is now locale.getpreferredencoding(False) (...) 10 In documentation of locale.getpreferredencoding fuction we can read: 8 11 9 The default encoding is now locale.getpreferredencoding(False) (...) 12 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. 10 13 11 In documentation of locale.getpreferredencoding fuction we can read:14 Here I found "hacky" but working method to overwrite these settings: 12 15 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. 16 In file settings.py of your django project add these lines: 14 17 15 Here I found "hacky" but working method to overwrite these settings: 16 17 In file settings.py of your django project add these lines: 18 19 import _locale 20 _locale._getdefaultlocale = (lambda *args: ['en_US', 'utf8'])" 18 import _locale 19 _locale._getdefaultlocale = (lambda *args: ['en_US', 'utf8'])"'' 21 20 22 21 In Python I can my "inspect _locale._getdefaultlocale" variable in my (Danish) Windows installation: