I have a project where I use EditorJS as a field in django admin.
It works rather well, but I discovered that django gives an error when I use non-ascii characters (i.e : àèç )
'ascii' codec can't encode character '\xe7' in position 188: ordinal not in range(128)
When I look directly in mySQL, the block data is saved as is :
{
"time":1716370689841,
"blocks":[
{
"id":"zDx7REc9dT",
"type":"SprayliveCard",
"data":{
"url":"/media/image_name.webp",
"text_content":"here the non-àsçîî characters"
}
}
],
"version":"2.21.0"}
mysql charset for this field is : utf8mb4 ( as it should be … ?)
The BIG issue, is that I don’t get this error when using django dev server, but only when using a local openlitespeed server through ubuntu/WSL2 ( and I suspect I will have the same problem once deployed to my linux instance)
I spent two days trying to solve this … with no success.
Outside of EditorJS, django has no issues with utf-8, and even is able to display non-ascii characters in a editorJS block !, but only in the admin model page. The error occurs only when I try to display the content of said block inside the page template. ( and again … it works fine with dev server on windows, but fails on ubuntu )
Oh by the way, I am parsing editorJS json data using a templatetag filter
Also, at some point in my search, I added this to settings.py :
FILE_CHARSET = 'utf-8'
DEFAULT_CHARSET = 'utf-8'
Does it help ?