V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2012-08-28 18:41:48 +08:00 · 2946 次点击
    这是一个创建于 4256 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我用 Django 写了一个很简单的博客程序,由于该程序没有既没有所见即所得的编辑器,也没有 markdown 编辑器,

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

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

    然后点击保存。。。

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

    3 条回复    1970-01-01 08:00:00 +08:00
    killpanda
        1
    killpanda  
       2012-08-28 18:45:45 +08:00
    记得是在模板那块这么写:
    {{ xxx |safe}}
    killpanda
        2
    killpanda  
       2012-08-28 18:48:06 +08:00
    markdown支持也超好加,看看这个文章:
    http://www.freewisdom.org/projects/python-markdown/Django
    pyKun
        3
    pyKun  
       2012-08-28 18:48:27 +08:00
    html的escaping 默认是开的,在开的情况下,想关掉某个地方用safe,全文都不想开改了autoescape就可以了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1474 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:20 · PVG 01:20 · LAX 10:20 · JFK 13:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.