{"title":"模板","version":"3.1","locale":"zh-hans","docname":"ref/templates/index","url":"/zh-hans/3.1/ref/templates/","canonical":"https://djangodocs.dev/zh-hans/3.1/ref/templates/","summary":"Django's template engine provides a powerful mini-language for defining the user-facing layer of your application, encouraging a clean separation of…","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's template engine provides a powerful mini-language for defining the\nuser-facing layer of your application, encouraging a clean separation of\napplication and presentation logic. Templates can be maintained by anyone with\nan understanding of HTML; no knowledge of Python is required. For introductory\nmaterial, see <a class=\"reference internal\" href=\"/zh-hans/3.1/topics/templates/\"><span class=\"doc\">模板</span></a> topic guide.</p>\n<div class=\"toctree-wrapper compound\">\n<ul>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/language/\">Django 模板语言</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/language/#templates\">模板</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/language/#variables\">变量</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/language/#filters\">过滤器</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/language/#tags\">标签</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/language/#comments\">注释</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/language/#template-inheritance\">模板继承</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/language/#automatic-html-escaping\">自动 HTML 转义</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/language/#accessing-method-calls\">访问方法调用</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/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.1/ref/templates/builtins/\">内置模板标签和过滤器</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/builtins/#built-in-tag-reference\">内置标签参考</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/builtins/#built-in-filter-reference\">内置过滤器参考</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/builtins/#internationalization-tags-and-filters\">国际化标签和过滤器</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/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.1/ref/templates/api/\">Django 模板语言：对于 Python 开发者</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/api/#overview\">概况</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/api/#configuring-an-engine\">设置引擎</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/api/#loading-a-template\">加载模板</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/api/#rendering-a-context\">渲染上下文</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/api/#playing-with-context-objects\">使用 <code class=\"docutils literal notranslate\">Context</code> 对象</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/api/#loading-templates\">加载模板</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/api/#custom-loaders\">自定义加载器</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.1/ref/templates/api/#template-origin\">模板起源</a></li>\n</ul>\n</li>\n</ul>\n</div>\n<aside class=\"admonition admonition-seealso\" role=\"note\">\n<p class=\"admonition-title\">See also</p>\n<p>For information on writing your own custom tags and filters, see\n<a class=\"reference internal\" href=\"/zh-hans/3.1/howto/custom-template-tags/\"><span class=\"doc\">自定义模板标签和过滤器</span></a>.</p>\n<p>To learn how to override templates in other Django applications, see\n<a class=\"reference internal\" href=\"/zh-hans/3.1/howto/overriding-templates/\"><span class=\"doc\">复写模板</span></a>.</p>\n</aside>","rootId":"templates","toc":[],"breadcrumbs":[{"docname":"ref/index","title":"API 参考","url":"/zh-hans/3.1/ref/"}],"prev":{"docname":"ref/signals","title":"信号","url":"/zh-hans/3.1/ref/signals/"},"next":{"docname":"ref/templates/language","title":"Django 模板语言","url":"/zh-hans/3.1/ref/templates/language/"},"formats":{"html":"/zh-hans/3.1/ref/templates/","markdown":"/zh-hans/3.1/ref/templates.md","json":"/zh-hans/3.1/ref/templates.json"},"source":"https://github.com/django/django/blob/stable/3.1.x/docs/ref/templates/index.txt","official":"https://docs.djangoproject.com/zh-hans/3.1/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","pt-br","ko","es","el","pl"]}