{"title":"模板","version":"3.2","locale":"zh-hans","docname":"ref/templates/index","url":"/zh-hans/3.2/ref/templates/","canonical":"https://djangodocs.dev/zh-hans/3.2/ref/templates/","summary":"Django 的模板引擎提供了一个强大的迷你语言来定义你的应用程序的面向用户层，鼓励应用程序和表现逻辑的清晰分离。任何懂 HTML 的人都可以维护模板，不需要 Python 知识。关于入门材料，请参见 模板 主题指南。 Django 模板语言 模板 变量 过滤器 标签 注释 模板继承 自动 HTML 转义 访问方法调用…","html":"<h1>模板<a class=\"heading-anchor\" href=\"#templates\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>Django 的模板引擎提供了一个强大的迷你语言来定义你的应用程序的面向用户层，鼓励应用程序和表现逻辑的清晰分离。任何懂 HTML 的人都可以维护模板，不需要 Python 知识。关于入门材料，请参见 <a class=\"reference internal\" href=\"/zh-hans/3.2/topics/templates/\"><span class=\"doc\">模板</span></a> 主题指南。</p>\n<div class=\"toctree-wrapper compound\">\n<ul>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/language/\">Django 模板语言</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/language/#templates\">模板</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/language/#variables\">变量</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/language/#filters\">过滤器</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/language/#tags\">标签</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/language/#comments\">注释</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/language/#template-inheritance\">模板继承</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/language/#automatic-html-escaping\">自动 HTML 转义</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/language/#accessing-method-calls\">访问方法调用</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/language/#custom-tag-and-filter-libraries\">自定义标签和过滤器库</a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/builtins/\">内置模板标签和过滤器</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/builtins/#built-in-tag-reference\">内置标签参考</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/builtins/#built-in-filter-reference\">内置过滤器参考</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/builtins/#internationalization-tags-and-filters\">国际化标签和过滤器</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/builtins/#other-tags-and-filters-libraries\">其他标签和过滤器库</a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/api/\">Django 模板语言：对于 Python 开发者</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/api/#overview\">概况</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/api/#configuring-an-engine\">设置引擎</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/api/#loading-a-template\">加载模板</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/api/#rendering-a-context\">渲染上下文</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/api/#playing-with-context-objects\">使用 <code class=\"docutils literal notranslate\"><span class=\"pre\">Context</span></code> 对象</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/api/#loading-templates\">加载模板</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/api/#custom-loaders\">自定义加载器</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.2/ref/templates/api/#template-origin\">模板起源</a></li>\n</ul>\n</li>\n</ul>\n</div>\n<aside class=\"admonition admonition-seealso\">\n<p class=\"admonition-title\">See also</p>\n<p>关于编写自定义标签和过滤器的信息，请参见 <a class=\"reference internal\" href=\"/zh-hans/3.2/howto/custom-template-tags/\"><span class=\"doc\">自定义模板标签和过滤器</span></a>。</p>\n<p>要学习如何在其他 Django 应用中覆盖模板，请看 <a class=\"reference internal\" href=\"/zh-hans/3.2/howto/overriding-templates/\"><span class=\"doc\">复写模板</span></a>。</p>\n</aside>","rootId":"templates","toc":[],"breadcrumbs":[{"docname":"ref/index","title":"API 参考","url":"/zh-hans/3.2/ref/"}],"prev":{"docname":"ref/signals","title":"信号","url":"/zh-hans/3.2/ref/signals/"},"next":{"docname":"ref/templates/language","title":"Django 模板语言","url":"/zh-hans/3.2/ref/templates/language/"},"formats":{"html":"/zh-hans/3.2/ref/templates/","markdown":"/zh-hans/3.2/ref/templates.md","json":"/zh-hans/3.2/ref/templates.json"},"source":"https://github.com/django/django/blob/stable/3.2.x/docs/ref/templates/index.txt","official":"https://docs.djangoproject.com/zh-hans/3.2/ref/templates/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0"],"inLocales":["en","zh-hans","fr","ja","id","it","pt-br","ko","es","el","pl"]}