Demand:Sometimes you need to return html code directly from the background with corresponding css, so that you don't have to write a bunch of embedded code in the front-end to make judgments.
When django transfers html code from views to templates, the default is not to render this html code, for security reasons.
And in order to render the html code, some extra code needs to be added:
from import mark_safe deploy_success = mark_safe('<span class="label label-success">Successful deployment</span>') ## and then use {{ deploy_success }} on the front end to render it successfully
Additional knowledge: Django back-end to the front-end directly pass html language to prevent the escape method (2 kinds)
Purpose, in order to allow the front-end to transmit to the back-end of this way does not escape the
1. Use mark_safe()
from import mark_safe # backend safe
2. Use safe filters
{{ value|safe }}
The above example of this django return html code from the backend is all I have to share with you, I hope to give you a reference, and I hope you will support me more.