Changes between Version 1 and Version 2 of Ticket #32439


Ignore:
Timestamp:
Feb 12, 2021, 4:00:38 AM (3 years ago)
Author:
helmstedt
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32439 – Description

    v1 v2  
    44
    55The 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:
    68
    7    "To save json data in django the TextIOWrapper is used:
     9The default encoding is now locale.getpreferredencoding(False) (...)
     10In documentation of locale.getpreferredencoding fuction we can read:
    811
    9     The default encoding is now locale.getpreferredencoding(False) (...)
     12Return 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.
    1013
    11    In documentation of locale.getpreferredencoding fuction we can read:
     14Here I found "hacky" but working method to overwrite these settings:
    1215
    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.
     16In file settings.py of your django project add these lines:
    1417
    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'])"
     18import _locale
     19_locale._getdefaultlocale = (lambda *args: ['en_US', 'utf8'])"''
    2120
    2221In Python I can my "inspect _locale._getdefaultlocale" variable in my (Danish) Windows installation:
Back to Top