From 65c9934936f1e59c6c344428dfd1a189043af999 Mon Sep 17 00:00:00 2001 From: Jonathan Liuti Date: Sun, 25 May 2014 15:39:43 +0200 Subject: [PATCH] Fix #129, force_unicode on body to make sure it's not a proxy object anymore --- djangocms_text_ckeditor/models.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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)