diff --git a/djangocms_text_ckeditor/models.py b/djangocms_text_ckeditor/models.py index 60bbc54..be7777c 100644 --- a/djangocms_text_ckeditor/models.py +++ b/djangocms_text_ckeditor/models.py @@ -1,12 +1,16 @@ import re +import sys + +from django.utils.encoding import force_unicode from django.db import models -from cms.models import CMSPlugin from django.utils.html import strip_tags from django.utils.text import Truncator from django.utils.translation import ugettext_lazy as _ -import sys -from djangocms_text_ckeditor.utils import plugin_tags_to_id_list, replace_plugin_tags, plugin_to_tag -from djangocms_text_ckeditor.html import clean_html, extract_images + +from cms.models import CMSPlugin + +from .utils import plugin_tags_to_id_list, replace_plugin_tags, plugin_to_tag +from .html import clean_html, extract_images class AbstractText(CMSPlugin): @@ -22,6 +26,10 @@ class AbstractText(CMSPlugin): def __unicode__(self): return Truncator(strip_tags(self.body)).words(3, truncate="...") + def __init__(self, *args, **kwargs): + super(AbstractText, self).__init__(*args, **kwargs) + self.body = force_unicode(self.body) + def save(self, *args, **kwargs): body = self.body body = extract_images(body, self)