推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
YUCOAT
V2EX  ›  Python

用 Django 写博客程序遇到的 html tag 转义的问题

  •  
  •   YUCOAT · Aug 28, 2012 · 3960 views
    This topic created in 5142 days ago, the information mentioned may be changed or developed.
    我用 Django 写了一个很简单的博客程序,由于该程序没有既没有所见即所得的编辑器,也没有 markdown 编辑器,

    于是在发表博文的时候我都是这样发表的:

    <h1>这是标题</h1>
    <p>就这样了?</p>

    然后点击保存。。。

    然后浏览器打开的时候,变成这个样子了:

    3 replies  •  1970-01-01 08:00:00 +08:00
    killpanda
        1
    killpanda  
       Aug 28, 2012
    记得是在模板那块这么写:
    {{ xxx |safe}}
    killpanda
        2
    killpanda  
       Aug 28, 2012
    markdown支持也超好加,看看这个文章:
    http://www.freewisdom.org/projects/python-markdown/Django
    pyKun
        3
    pyKun  
       Aug 28, 2012
    html的escaping 默认是开的,在开的情况下,想关掉某个地方用safe,全文都不想开改了autoescape就可以了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1177 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:29 · PVG 01:29 · LAX 10:29 · JFK 13:29
    ♥ Do have faith in what you're doing.