django: tinymce and unicode
-
01-07-2021 - |
Question
I am using django-tinymce v1.5.1b2.
I am also using an HTMLField() model field like this:
class Page(models.Model):
title = models.CharField(max_length=512)
slug = models.SlugField(max_length=512, default='', blank=True)
content = tinymce_models.HTMLField(blank=True)
Everything works fine.
However I noticed that when I save the page, I get this in the content field in my MySQL database
<p>Από τα χρόνια του Ιπποκράτη...
Why is that? I know that MySQL supports utf data. Can I change tinymce's behaviour to store normal utf characters and not html codes?
It is important for me, because I intent to create a new tag that would parse the content to find certain words and add some extra HTML just before displaying it to the user.
Solution
I found the solution. I am posting it here for anyone having the same problem, to see.
I just added this line in my TINYMCE_DEFAULT_CONFIG
dictionary in setting.py
TINYMCE_DEFAULT_CONFIG = {
'entity_encoding': 'raw',
}
OTHER TIPS
I think you can use the {{"the value you will display with tiny_mce in html"|safe}},then I think the problem will slove You can also see here: Why does TinyMCE in Django admin output HTML tags?