pip install markdown pygments
For example,
model named Blog
markdown field name content
class based view
def get_content_data(self, **kwargs):
md = markdown.Markdown(extensions=['fenced_code'])
context = super().get_context_data(**kwargs)
context['object'].content = md.convert(self.object.content)
return context
in template
{{ object.content | safe }}