Is it possible to display the HTML provided by the admin panel app on-site?

Viewed 16

I've built a site where I can create new posts (essays) by the admin panel. The output is visible to users. But when I place some HTML as content in the form it doesn't render itself on the page.

example:

enter image description here

Output on the page (with marked unrendered HTML):

enter image description here

I would like to know how to fix it and also, how to name the topic I want to know ( I couldn't find anything related to my problem, probably because I don't know how to express it).

Additionally, I just start to wonder if there is one more problem nested inside. How to link CSS from the static folder having this HTML mentioned above?

1 Answers

Django offer the autoescape template in the builtins tags

{% autoescape off %}
{{ myhtml }}
{% endautoescape %}

But your logic seems wrong, you don't need to create a new page with the doctype, just create a base template and use the block content tag to insert your article.

In your base template replace the description and title of your page by variables that will be populated by the article data.

You need to learn the basic of Django https://docs.djangoproject.com/en/4.1/ trust me you won't regret it !

Related