I have created a small blog that includes django-tinymce in model.py file. After I write a text in the Admin console and publish it, the text is shown with HTML tags. Please see the example bellow:
This is my model.py file:
from django.conf import settings
from django.db import models
from django.utils import timezone
from tinymce.models import HTMLField
class Post(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(blank=True, null=True)
text = HTMLField()
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
I can't find any reason why it is happening. I followed the documentation and should get a text without any tags.
make sure you use like this {{ text|safe }} in your template.