{"title":"contrib 包","version":"4.0","locale":"zh-hans","docname":"ref/contrib/index","url":"/zh-hans/4.0/ref/contrib/","canonical":"https://djangodocs.dev/zh-hans/4.0/ref/contrib/","summary":"Django aims to follow Python's \"batteries included\" philosophy. It ships with a variety of extra, optional tools that solve common web development problems.","html":"<h1><code class=\"docutils literal notranslate\">contrib</code> 包<a class=\"heading-anchor\" href=\"#contrib-packages\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>Django aims to follow Python's <a class=\"reference external\" href=\"https://docs.python.org/3/tutorial/stdlib.html#tut-batteries-included\" title=\"(in Python v3.14)\"><span class=\"xref std std-ref\">&quot;batteries included&quot; philosophy</span></a>. It ships with a variety of extra, optional tools\nthat solve common web development problems.</p>\n<p>这段代码位于 Django 发行版中的 <code class=\"docutils literal notranslate\">django/contrib</code> 中。本文档给出了 <code class=\"docutils literal notranslate\">contrib</code> 中的包的概要，以及这些包的依赖关系。</p>\n<aside class=\"admonition-note admonition\" role=\"note\">\n<p class=\"admonition-title\">注解</p>\n<p>对于大多数这些附加组件 —— 特别是包括模型或模板标签的附加组件 —— 你需要在你的 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> 配置中添加包名（例如 <code class=\"docutils literal notranslate\">'django.contrib.redirects'</code>），并重新运行 <code class=\"docutils literal notranslate\">manage.py migrate</code>。</p>\n</aside>\n<div class=\"toctree-wrapper compound\">\n<ul>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/admin/\">Django 管理站点</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/auth/\"><code class=\"docutils literal notranslate\">django.contrib.auth</code></a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/contenttypes/\">内容类型框架</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/flatpages/\">简单页面应用</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/gis/\">GeoDjango</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/humanize/\"><code class=\"docutils literal notranslate\">django.contrib.humanize</code></a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/messages/\">消息框架</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/postgres/\"><code class=\"docutils literal notranslate\">django.contrib.postgres</code></a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/redirects/\">重定向应用</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/sitemaps/\">站点地图框架</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/sites/\">“站点”框架</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/staticfiles/\"><code class=\"docutils literal notranslate\">staticfiles</code> 应用</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/syndication/\">Feed 聚合框架</a></li>\n</ul>\n</div>\n<section id=\"admin\">\n<h2><code class=\"docutils literal notranslate\">admin</code><a class=\"heading-anchor\" href=\"#admin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django 自动管理界面。更多信息请参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/intro/tutorial02/\"><span class=\"doc\">教程 2</span></a> 和 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/admin/\"><span class=\"doc\">管理文档</span></a>。</p>\n<p>需要安装 <a class=\"reference internal\" href=\"#auth\">auth</a> 和 <a class=\"reference internal\" href=\"#contenttypes\">contenttypes</a> contrib 包。</p>\n</section>\n<section id=\"auth\">\n<h2><code class=\"docutils literal notranslate\">auth</code><a class=\"heading-anchor\" href=\"#auth\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django 的认证框架。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/topics/auth/\"><span class=\"doc\">Django中的用户认证</span></a>。</p>\n</section>\n<section id=\"contenttypes\">\n<h2><code class=\"docutils literal notranslate\">contenttypes</code><a class=\"heading-anchor\" href=\"#contenttypes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一个轻量级的框架，用于钩入 “多种类型” 的内容，每个安装的 Django 模型都是一个独立的内容类型。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/contenttypes/\"><span class=\"doc\">contenttypes 文档</span></a>。</p>\n</section>\n<section id=\"flatpages\">\n<h2><code class=\"docutils literal notranslate\">flatpages</code><a class=\"heading-anchor\" href=\"#flatpages\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一个在数据库中管理 “简单” HTML 内容的框架。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/flatpages/\"><span class=\"doc\">简单页面文档</span></a>。</p>\n<p>需要同时安装 <a class=\"reference internal\" href=\"#sites\">sites</a> contrib 包。</p>\n</section>\n<section id=\"gis\">\n<h2><code class=\"docutils literal notranslate\">gis</code><a class=\"heading-anchor\" href=\"#gis\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一个建立在 Django 之上的世界级地理空间框架，可以实现空间数据的存储、操作和显示。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/gis/\"><span class=\"doc\">GeoDjango</span></a> 文档。</p>\n</section>\n<section id=\"humanize\">\n<h2><code class=\"docutils literal notranslate\">humanize</code><a class=\"heading-anchor\" href=\"#humanize\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一套 Django 模板过滤器，用于为数据添加 “人情味”。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/humanize/\"><span class=\"doc\">人性化文档</span></a>。</p>\n</section>\n<section id=\"messages\">\n<h2><code class=\"docutils literal notranslate\">messages</code><a class=\"heading-anchor\" href=\"#messages\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一个存储和检索基于 cookie 或会话的临时消息的框架。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/messages/\"><span class=\"doc\">消息文档</span></a>。</p>\n</section>\n<section id=\"postgres\">\n<h2><code class=\"docutils literal notranslate\">postgres</code><a class=\"heading-anchor\" href=\"#postgres\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一个 PostgreSQL 特定功能的集合。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/postgres/\"><span class=\"doc\">contrib.postgres 文档</span></a>。</p>\n</section>\n<section id=\"redirects\">\n<h2><code class=\"docutils literal notranslate\">redirects</code><a class=\"heading-anchor\" href=\"#redirects\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一个管理重定向的框架。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/redirects/\"><span class=\"doc\">重定向文档</span></a>。</p>\n</section>\n<section id=\"sessions\">\n<h2><code class=\"docutils literal notranslate\">sessions</code><a class=\"heading-anchor\" href=\"#sessions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一个在匿名会话中存储数据的框架。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/topics/http/sessions/\"><span class=\"doc\">会话文档</span></a>。</p>\n</section>\n<section id=\"sites\">\n<h2><code class=\"docutils literal notranslate\">sites</code><a class=\"heading-anchor\" href=\"#sites\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一个轻量级的框架，可以让你在同一个数据库和 Django 安装下操作多个网站。它为你提供了将对象关联到一个或多个网站的钩子。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/sites/\"><span class=\"doc\">站点文档</span></a>。</p>\n</section>\n<section id=\"sitemaps\">\n<h2><code class=\"docutils literal notranslate\">sitemaps</code><a class=\"heading-anchor\" href=\"#sitemaps\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一个用于生成 Google 网站地图 XML 文件的框架。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/sitemaps/\"><span class=\"doc\">站点地图文档</span></a>。</p>\n</section>\n<section id=\"syndication\">\n<h2><code class=\"docutils literal notranslate\">syndication</code><a class=\"heading-anchor\" href=\"#syndication\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>以 RSS 和 Atom 形式很容易地生成聚合 feed 的框架。</p>\n<p>参见 <a class=\"reference internal\" href=\"/zh-hans/4.0/ref/contrib/syndication/\"><span class=\"doc\">聚合框架文档</span></a>。</p>\n</section>\n<section id=\"other-add-ons\">\n<h2>其他附加功能<a class=\"heading-anchor\" href=\"#other-add-ons\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>如果你有一个关于 <code class=\"docutils literal notranslate\">contrib</code> 的功能的想法，请告诉我们！把它写成代码，并发布到 <a class=\"reference internal\" href=\"/zh-hans/4.0/internals/mailing-lists/#django-users-mailing-list\"><span class=\"std std-ref\">django-users</span></a> 邮件列表。</p>\n</section>","rootId":"contrib-packages","toc":[{"title":"admin","anchor":"admin","children":[]},{"title":"auth","anchor":"auth","children":[]},{"title":"contenttypes","anchor":"contenttypes","children":[]},{"title":"flatpages","anchor":"flatpages","children":[]},{"title":"gis","anchor":"gis","children":[]},{"title":"humanize","anchor":"humanize","children":[]},{"title":"messages","anchor":"messages","children":[]},{"title":"postgres","anchor":"postgres","children":[]},{"title":"redirects","anchor":"redirects","children":[]},{"title":"sessions","anchor":"sessions","children":[]},{"title":"sites","anchor":"sites","children":[]},{"title":"sitemaps","anchor":"sitemaps","children":[]},{"title":"syndication","anchor":"syndication","children":[]},{"title":"其他附加功能","anchor":"other-add-ons","children":[]}],"breadcrumbs":[{"docname":"ref/index","title":"API 参考","url":"/zh-hans/4.0/ref/"}],"prev":{"docname":"ref/clickjacking","title":"点击劫持保护","url":"/zh-hans/4.0/ref/clickjacking/"},"next":{"docname":"ref/contrib/admin/index","title":"Django 管理站点","url":"/zh-hans/4.0/ref/contrib/admin/"},"formats":{"html":"/zh-hans/4.0/ref/contrib/","markdown":"/zh-hans/4.0/ref/contrib.md","json":"/zh-hans/4.0/ref/contrib.json"},"source":"https://github.com/django/django/blob/stable/4.0.x/docs/ref/contrib/index.txt","official":"https://docs.djangoproject.com/zh-hans/4.0/ref/contrib/","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"]}