Giter VIP home page Giter VIP logo

Comments (2)

tian-yan avatar tian-yan commented on July 17, 2024

I figured out myself, it is a very basic knowledge point (HTML Escaping) for Django actually. Apply safe Django template filter solves the problem.

in template file: Post_Detail.html

{% load wagtailmarkdown %}
<div class="markdown">
      {{ page.html_body|safe }}  
</div>

However, my original intention is minimize the workload of web server every time when the page is loaded by viewers.

So, I am wondering whether I should get rid of this safe or any template filter to further reduce the workload ? If yes, then how please ? I did not see possibility for saving {{ page.html_body|safe }} in database.

from wagtail-markdown.

zerolab avatar zerolab commented on July 17, 2024

|safe is a tempalte tag that uses mark_safe to mark the string as "safe" to be displayed unescaped in the template.

This is what render_markdown does too. However the fact that you mark it as safe then store it in the database means you're saving the processed HTML to the database, which by all intents and purposes is raw HTML which Django correctly encodes when output in the template, so using |safe is the way to go.

Given the above, I am closing this as this is working as intended by Django

from wagtail-markdown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.