{"title":"contrib 包","version":"5.0","locale":"zh-hans","docname":"ref/contrib/index","url":"/zh-hans/5.0/ref/contrib/","canonical":"https://djangodocs.dev/zh-hans/5.0/ref/contrib/","summary":"Django 的目标是遵循 Python 的 \"batteries included\" 哲学 。它附带了各种额外的、可选的工具，用于解决常见的 Web 开发问题。 这段代码位于 Django 分发版中的 django/contrib 中。本文档介绍了 contrib 中的包以及这些包的任何依赖关系。 将 contrib…","html":"<h1><code class=\"docutils literal notranslate\"><span class=\"pre\">contrib</span></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 的目标是遵循 Python 的 <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; 哲学</span></a>。它附带了各种额外的、可选的工具，用于解决常见的 Web 开发问题。</p>\n<p>这段代码位于 Django 分发版中的 <a class=\"extlink-source reference external\" href=\"https://github.com/django/django/blob/stable/5.0.x/django/contrib\">django/contrib</a> 中。本文档介绍了 <code class=\"docutils literal notranslate\"><span class=\"pre\">contrib</span></code> 中的包以及这些包的任何依赖关系。</p>\n<aside class=\"admonition-including-contrib-packages-in-installed-apps admonition\">\n<p class=\"admonition-title\">将 <code class=\"docutils literal notranslate\"><span class=\"pre\">contrib</span></code> 包包括在 <code class=\"docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code> 中</p>\n<p>对于大多数这些附加组件，特别是包含模型或模板标签的附加组件，您需要将包名（例如，<code class=\"docutils literal notranslate\"><span class=\"pre\">'django.contrib.redirects'</span></code>）添加到您的 <a class=\"reference internal\" href=\"/zh-hans/5.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> 设置中，然后重新运行 <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span> <span class=\"pre\">migrate</span></code>。</p>\n</aside>\n<div class=\"toctree-wrapper compound\">\n<ul>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/admin/\">Django 管理站点</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/auth/\"><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.auth</span></code></a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/contenttypes/\">内容类型框架</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/flatpages/\">简单页面应用</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/gis/\">GeoDjango</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/humanize/\"><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.humanize</span></code></a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/messages/\">消息框架</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/postgres/\"><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.postgres</span></code></a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/redirects/\">重定向应用</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/sitemaps/\">站点地图框架</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/sites/\">“站点”框架</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/staticfiles/\"><code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles</span></code> 应用</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/5.0/ref/contrib/syndication/\">Feed 聚合框架</a></li>\n</ul>\n</div>\n<section id=\"admin\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">admin</span></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/5.0/intro/tutorial02/\"><span class=\"doc\">教程 2</span></a> 和 <a class=\"reference internal\" href=\"/zh-hans/5.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\"><span class=\"pre\">auth</span></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/5.0/topics/auth/\"><span class=\"doc\">Django中的用户认证</span></a>。</p>\n</section>\n<section id=\"contenttypes\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">contenttypes</span></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/5.0/ref/contrib/contenttypes/\"><span class=\"doc\">contenttypes 文档</span></a>。</p>\n</section>\n<section id=\"flatpages\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">flatpages</span></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/5.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\"><span class=\"pre\">gis</span></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/5.0/ref/contrib/gis/\"><span class=\"doc\">GeoDjango</span></a> 文档。</p>\n</section>\n<section id=\"humanize\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">humanize</span></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/5.0/ref/contrib/humanize/\"><span class=\"doc\">人性化文档</span></a>。</p>\n</section>\n<section id=\"messages\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">messages</span></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/5.0/ref/contrib/messages/\"><span class=\"doc\">消息文档</span></a>。</p>\n</section>\n<section id=\"postgres\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">postgres</span></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/5.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\"><span class=\"pre\">redirects</span></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/5.0/ref/contrib/redirects/\"><span class=\"doc\">重定向文档</span></a>。</p>\n</section>\n<section id=\"sessions\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">sessions</span></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/5.0/topics/http/sessions/\"><span class=\"doc\">会话文档</span></a>。</p>\n</section>\n<section id=\"sites\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">sites</span></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/5.0/ref/contrib/sites/\"><span class=\"doc\">站点文档</span></a>。</p>\n</section>\n<section id=\"sitemaps\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">sitemaps</span></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/5.0/ref/contrib/sitemaps/\"><span class=\"doc\">站点地图文档</span></a>。</p>\n</section>\n<section id=\"syndication\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">syndication</span></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/5.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\"><span class=\"pre\">contrib</span></code> 的功能的想法，请告诉我们！把它写成代码，并发布到 <a class=\"reference internal\" href=\"/zh-hans/5.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/5.0/ref/"}],"prev":{"docname":"ref/clickjacking","title":"点击劫持保护","url":"/zh-hans/5.0/ref/clickjacking/"},"next":{"docname":"ref/contrib/admin/index","title":"Django 管理站点","url":"/zh-hans/5.0/ref/contrib/admin/"},"formats":{"html":"/zh-hans/5.0/ref/contrib/","markdown":"/zh-hans/5.0/ref/contrib.md","json":"/zh-hans/5.0/ref/contrib.json"},"source":"https://github.com/django/django/blob/stable/5.0.x/docs/ref/contrib/index.txt","official":"https://docs.djangoproject.com/zh-hans/5.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"]}