本文已默认你已经好创建Django工程和App。

pip install markdown django-markup bleach bleach-whitelist

示例代码

  • your_app/urls.py
urlpatterns = [
    path('about/', views.about, name="about"),
]
  • your_app/views.py
def about(request):
    content = ""
    with open("./templates/license.md", 'r') as f:
        content = formatter(f.read(), filter_name="markdown")
    return render(request, 'about.html', {"content":content})
  • templates/about.html
    {% load markup_tags %}
    {{ content|apply_markup:"markdown" }}


MARSGGBO原创





2019-9-3



相关文章:

  • 2021-05-19
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
  • 2021-07-25
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2021-12-18
  • 2022-02-01
相关资源
相似解决方案