Reputation: 405
I have built a blog with Django. In my BlogPost model I have a text field named "content". When I compose a blog post via the admin panel, any custom HTML (links, code blocks, external images) that I enter is rendered in the template as static, literal text - not it's true semantic HTML.
I want to create a blog that allows blog posts to use markdown. No one else is making posts except me, and there is not client-facing form throughout the entire site (except the admin login page). How do I turn off escaping so that I can use custom HTML like italics, bold, links, external images, h1's, h3's, paragraphs, etc in my blog posts?
I have been trying to find a resource to learn from but am coming up short. Should I use a preconfigured markdown app, or roll my own?
Upvotes: 0
Views: 241
Reputation: 662
One way is that You can use ck editor for admin to edit html with toolbar.
& You also need to mark as safe in template html otherwise it is rendered as plain text.
for example in template write below code:
{{ field_name |safe }}
Upvotes: 0
Reputation: 74
You can use mark_safe
django.utils.html.mark_safe
from view side
or in template you can achieve this by writing {{your_field | safe}}
.
also you can use your custom template tag too for this.
Upvotes: 2