I have installed Django Summernote by following the guide from GitHub and have successfully added it to my admin page. However, when I try to edit the text using summernote and view it on the HTML template, it shows the code view instead of the text only. I'm new to Django so I'm not sure what I'm missing here.
from django.contrib import admin
from django_summernote.admin import SummernoteModelAdmin
from .models import Post
class PostAdmin(SummernoteModelAdmin):
summernote_fields = ('body',)
admin.site.register(Post, PostAdmin)
from django.db import models
from django.contrib.auth.models import User
class Post(models.Model):
...
body = models.TextField()
...
def __str__(self):
return self.title
{% block body %}
...
<p>{{ post.body }}</p>
...
{% endblock %}
You will need to use safe filter here.
Safe Marks a string as not requiring further HTML escaping prior to output. When autoescaping is off, this filter has no effect.
Your edit:
<p>{{ post.body | safe }}</p>