romanvm / django-tinymce4-lite

TinyMCE 4 editor widget for Django
MIT License
126 stars 47 forks source link

HTML code displayed in template view of TinyMCE input #28

Closed AoiToShiro closed 6 years ago

AoiToShiro commented 6 years ago

Hi, thank you for your hard work, I am having problems (web development is very new to me), but I can see that this is a very useful tool.

I have installed django-tinymce4-lite==1.7.0 along with django-filebrowser-no-grappelli==3.7.4. I am able to clearly see the TinyMCE browser to assist with formatting within the admin module, but any changes I make are then displayed with the HTML used. For example, I added bold to the first line of my test blog and I see the following on the page:

"

Also testing a different sized image. "

EDIT: added an image of what I can see as the above quote simply changed into how I expected to view it. image

I am using Django 2.0.2 and Python version 3.6.4. I'm not sure what I've missed?

One other quick question, I may be experiencing some issues with the media file location, but just to clarify, when trying to insert an image TinyMCE requests "Source", can I use django tags, i.e. {% static 'images/AnImage.png' %}?

Thanks in advance for your time.

romanvm commented 6 years ago
  1. It seems that your HTML content is auto-escaped by Django. You need to carefully read the documentation: http://romanvm.github.io/django-tinymce4-lite/usage.html

  2. No, you cannot use Django tags in TinyMCE content because this content is not the part of a template.

AoiToShiro commented 6 years ago

Thank you for getting back so swiftly. I thought I had read the documentation carefully, I coded the following: {{ post.body|truncatewords:10|linebreaks|safe }} This was, as you have stated, being auto escaped. I have moved the |safe element next to the post.body and I can see now that the HTML content has gone. Thank you for that.

I am now getting strange behaviour on the formatting of this page, but I will try to work that out before bugging anyone.