How to bold text in template using django template tags

For example if I want to put an 'About' section or a 'Terms of Use' section in my website and want some of the subheadings to be bolded or made into headers. How could I use template tags to achieve this? My plan is to write the About section or Terms of Use in my models and use template tags to format the subheadings and any text that should be bolded. Is there a better way to do this?

There is already a language to specify how to style text, is it named the Hypertext Markup Language (HTML) [wiki]. You can thus write the text as HTML in the model:

class MyModel(models.Model):
    html = models.TextField()

In the template, you then prevent Django from escaping the content with the |safe template filter [Django-doc]:

{{my_object.html|safe }}
Вернуться на верх