{"title":"系统检查框架","version":"3.0","locale":"zh-hans","docname":"ref/checks","url":"/zh-hans/3.0/ref/checks/","canonical":"https://djangodocs.dev/zh-hans/3.0/ref/checks/","summary":"系统检查框架是一组验证Django项目的静态检查。它检测到常见的问题，并提供了如何解决这些问题的提示。该框架是可扩展的，所以你可以轻松地添加自己的检查。","html":"<h1>系统检查框架<a class=\"heading-anchor\" href=\"#system-check-framework\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>系统检查框架是一组验证Django项目的静态检查。 它检测到常见的问题，并提供了如何解决这些问题的提示。 该框架是可扩展的，所以你可以轻松地添加自己的检查。</p>\n<p>有关如何添加自己的检查并将其与 Django 的系统检查集成的详细信息，请参阅：doc：系统检查主题指南&lt;/topics/checks&gt;。</p>\n<section id=\"api-reference\">\n<h2>API 参考<a class=\"heading-anchor\" href=\"#api-reference\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"checkmessage\">\n<h3>“CheckMessage”<a class=\"heading-anchor\" href=\"#checkmessage\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.core.checks.CheckMessage\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">CheckMessage</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">level</em>, <em class=\"sig-param\">msg</em>, <em class=\"sig-param\">hint<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">obj<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">id<span class=\"o\">=</span><span class=\"default_value\">None</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.checks.CheckMessage\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>系统检查提出的警告和错误必须是“CheckMessage”的实例。 一个实例封装了一个可报告的错误或警告。 它还提供适用于消息的上下文和提示以及用于过滤目的的唯一标识符。</p>\n<p>构造方法的参数：</p>\n<dl class=\"simple\">\n<dt><code class=\"docutils literal notranslate\">level</code></dt><dd><p>消息的严重性。 使用其中一个预定义的值：DEBUG，INFO，WARNING，ERROR，CRITICAL。 如果级别大于或等于“ERROR”，则Django将阻止执行管理命令。 级别低于“ERROR”的消息（即警告）被报告给控制台，但是可以被静默。</p>\n</dd>\n<dt><code class=\"docutils literal notranslate\">msg</code></dt><dd><p>用来描述问题的一个简短字符串(少于80个字符)。这个字符串不应该包含换行符。</p>\n</dd>\n<dt><code class=\"docutils literal notranslate\">hint</code></dt><dd><p>提供解决问题的提示的单行字符串。 如果不能提供提示，或者错误消息中的提示是显而易见的，则提示可以省略，或者可以使用“None”的值。</p>\n</dd>\n<dt><code class=\"docutils literal notranslate\">obj</code></dt><dd><p>Optional. An object providing context for the message (for example, the\nmodel where the problem was discovered). The object should be a model,\nfield, or manager or any other object that defines a <code class=\"docutils literal notranslate\">__str__()</code> method.\nThe method is used while reporting all messages and its result precedes the\nmessage.</p>\n</dd>\n<dt><code class=\"docutils literal notranslate\">id</code></dt><dd><p>Optional string. A unique identifier for the issue. Identifiers should\nfollow the pattern <code class=\"docutils literal notranslate\">applabel.X001</code>, where <code class=\"docutils literal notranslate\">X</code> is one of the letters\n<code class=\"docutils literal notranslate\">CEWID</code>, indicating the message severity (<code class=\"docutils literal notranslate\">C</code> for criticals, <code class=\"docutils literal notranslate\">E</code> for\nerrors and so). The number can be allocated by the application, but should\nbe unique within that application.</p>\n</dd>\n</dl>\n<p>有一些子类可以使创建通用级别的消息更简单。 当使用它们时，可以省略“level”参数，因为它是由类名所隐含的。</p>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.core.checks.Debug\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">Debug</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">msg</em>, <em class=\"sig-param\">hint<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">obj<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">id<span class=\"o\">=</span><span class=\"default_value\">None</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.checks.Debug\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.core.checks.Info\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">Info</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">msg</em>, <em class=\"sig-param\">hint<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">obj<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">id<span class=\"o\">=</span><span class=\"default_value\">None</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.checks.Info\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.core.checks.Warning\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">Warning</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">msg</em>, <em class=\"sig-param\">hint=None obj=None</em>, <em class=\"sig-param\">id=None</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.checks.Warning\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.core.checks.Error\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">Error</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">msg</em>, <em class=\"sig-param\">hint<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">obj<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">id<span class=\"o\">=</span><span class=\"default_value\">None</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.checks.Error\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.core.checks.Critical\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">Critical</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">msg</em>, <em class=\"sig-param\">hint<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">obj<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">id<span class=\"o\">=</span><span class=\"default_value\">None</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.checks.Critical\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n</section>\n</section>\n<section id=\"builtin-tags\">\n<span id=\"system-check-builtin-tags\"></span><h2>内置标签<a class=\"heading-anchor\" href=\"#builtin-tags\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django 的系统检查按以下标签组织：</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">admin</code>：检查所有后台站点申明。</p></li>\n<li><p><code class=\"docutils literal notranslate\">caches</code>：检查缓存相关的配置。</p></li>\n<li><p><code class=\"docutils literal notranslate\">compatibility</code>：标记版本升级可能导致的问题。</p></li>\n<li><p><code class=\"docutils literal notranslate\">database</code>: Checks database-related configuration issues. Database checks\nare not run by default because they do more than static code analysis as\nregular checks do. They are only run by the <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/django-admin/#django-admin-migrate\"><code class=\"xref std std-djadmin docutils literal notranslate\">migrate</code></a> command or if\nyou specify the <code class=\"docutils literal notranslate\">database</code> tag when calling the <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/django-admin/#django-admin-check\"><code class=\"xref std std-djadmin docutils literal notranslate\">check</code></a> command.</p></li>\n<li><p><code class=\"docutils literal notranslate\">models</code>：检查模型，字段和管理器定义。</p></li>\n<li><p><code class=\"docutils literal notranslate\">security</code>：检查安全相关配置。</p></li>\n<li><p><code class=\"docutils literal notranslate\">signals</code>：检查信号申明和处理器注册信息。</p></li>\n<li><p><code class=\"docutils literal notranslate\">staticfiles</code>：检查 <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/staticfiles/#module-django.contrib.staticfiles\" title=\"django.contrib.staticfiles: An app for handling static files.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.staticfiles</code></a> 配置。</p></li>\n<li><p><code class=\"docutils literal notranslate\">templates</code>：检查模板相关配置。</p></li>\n<li><p><code class=\"docutils literal notranslate\">translation</code>：检查翻译相关配置。</p></li>\n<li><p><code class=\"docutils literal notranslate\">urls</code>：检查 URL 配置。</p></li>\n</ul>\n<p>一些可能通过多个标签同时注册的检查项。</p>\n</section>\n<section id=\"core-system-checks\">\n<h2>核心系统检查<a class=\"heading-anchor\" href=\"#core-system-checks\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"backwards-compatibility\">\n<h3>向后兼容<a class=\"heading-anchor\" href=\"#backwards-compatibility\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>兼容性检查警告那些升级 Django 后可能出现的问题。</p>\n<ul class=\"simple\">\n<li><p><strong>2_0.W001</strong>: Your URL pattern <code class=\"docutils literal notranslate\">&lt;pattern&gt;</code> has a <code class=\"docutils literal notranslate\">route</code> that contains\n<code class=\"docutils literal notranslate\">(?P&lt;</code>, begins with a <code class=\"docutils literal notranslate\">^</code>, or ends with a <code class=\"docutils literal notranslate\">$</code>. This was likely an\noversight when migrating from <code class=\"docutils literal notranslate\">url()</code> to <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/urls/#django.urls.path\" title=\"django.urls.path\"><code class=\"xref py py-func docutils literal notranslate\">path()</code></a>.</p></li>\n</ul>\n</section>\n<section id=\"caches\">\n<h3>缓存<a class=\"heading-anchor\" href=\"#caches\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The following checks verify that your <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-CACHES\"><code class=\"xref std std-setting docutils literal notranslate\">CACHES</code></a> setting is correctly\nconfigured:</p>\n<ul class=\"simple\">\n<li><p><strong>caches.E001</strong>: You must define a <code class=\"docutils literal notranslate\">'default'</code> cache in your\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-CACHES\"><code class=\"xref std std-setting docutils literal notranslate\">CACHES</code></a> setting.</p></li>\n</ul>\n</section>\n<section id=\"database\">\n<h3>数据库<a class=\"heading-anchor\" href=\"#database\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"mysql\">\n<h4>MySQL<a class=\"heading-anchor\" href=\"#mysql\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>如果您使用MySQL，需要执行以下检查：</p>\n<ul class=\"simple\">\n<li><p><strong>mysql.E001</strong>: MySQL does not allow unique <code class=\"docutils literal notranslate\">CharField</code>s to have a\n<code class=\"docutils literal notranslate\">max_length</code> &gt; 255.</p></li>\n<li><p><strong>mysql.W002</strong>: MySQL Strict Mode is not set for database connection\n<code class=\"docutils literal notranslate\">&lt;alias&gt;</code>. See also <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/databases/#mysql-sql-mode\"><span class=\"std std-ref\">Setting sql_mode</span></a>.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"model-fields\">\n<h3>模型字段<a class=\"heading-anchor\" href=\"#model-fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<ul class=\"simple\">\n<li><p><strong>fields.E001</strong>: 字段名不能已下划线结尾。</p></li>\n<li><p><strong>fields.E002</strong>: 字段名不能有 <code class=\"docutils literal notranslate\">&quot;__&quot;</code>.</p></li>\n<li><p><em>fields.E003*</em>: <code class=\"docutils literal notranslate\">pk</code> 是保留关键字，不能作为字段名使用。</p></li>\n<li><p>** fields.E004 <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">**</span></a>：“choices”必须是可迭代的（例如，列表或元组）。</p></li>\n<li><p>** fields.E005 <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">**</span></a>：<a href=\"#id3\"><span class=\"problematic\" id=\"id4\">``</span></a>choices``必须是一个可返回的``（实际值，易读的名称）``构成元组。</p></li>\n<li><p>** fields.E006 <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">**</span></a>：<code class=\"docutils literal notranslate\">db_index``必须是`None`，``True``或`False</code>。</p></li>\n<li><p>** fields.E007 <a href=\"#id1\"><span class=\"problematic\" id=\"id2\">**</span></a>：主键不能有“null = True”。</p></li>\n<li><p><strong>fields.E008</strong>：所有 <code class=\"docutils literal notranslate\">validators</code> 必须都是可调用的。</p></li>\n<li><p><strong>fields.E009</strong>: <code class=\"docutils literal notranslate\">max_length</code> is too small to fit the longest value in\n<code class=\"docutils literal notranslate\">choices</code> (<code class=\"docutils literal notranslate\">&lt;count&gt;</code> characters).</p></li>\n<li><p><strong>fields.E100</strong>： <code class=\"docutils literal notranslate\">AutoField`</code> 必须设置 primary_key=True。</p></li>\n<li><p><strong>fields.E110</strong>: <code class=\"docutils literal notranslate\">BooleanField</code>s do not accept null values. <em>This check\nappeared before support for null values was added in Django 2.1.</em></p></li>\n<li><p><strong>fields.E120</strong>： <code class=\"docutils literal notranslate\">CharField</code> 必须定义一个 <code class=\"docutils literal notranslate\">max_length</code> 属性。</p></li>\n<li><p><strong>fields.E121</strong>： <code class=\"docutils literal notranslate\">max_length</code> 必须是个正整数。</p></li>\n<li><p><strong>fields.W122</strong>： <code class=\"docutils literal notranslate\">max_length</code> 在使用 <code class=\"docutils literal notranslate\">&lt;integer field type&gt;</code> 时会被忽略。</p></li>\n<li><p><strong>fields.E130</strong>： <code class=\"docutils literal notranslate\">DecimalField</code> 必须定义一个 <code class=\"docutils literal notranslate\">decimal_places</code> 属性。</p></li>\n<li><p><strong>fields.E131</strong>： <code class=\"docutils literal notranslate\">decimal_places</code> 必须是个非负整数。</p></li>\n<li><p><strong>fields.E132</strong>： <code class=\"docutils literal notranslate\">DecimalField</code> 必须定义一个 <code class=\"docutils literal notranslate\">max_digits</code> 属性。</p></li>\n<li><p><strong>fields.E133</strong>： <code class=\"docutils literal notranslate\">max_digits</code> 必须是一个非负整数。</p></li>\n<li><p><strong>fields.E134</strong>： <code class=\"docutils literal notranslate\">max_digits</code> 必须大于或等于 <code class=\"docutils literal notranslate\">decimal_places</code>。</p></li>\n<li><p><strong>fields.E140</strong>： <code class=\"docutils literal notranslate\">FilePathField</code> 的 <code class=\"docutils literal notranslate\">allow_files</code> 或 <code class=\"docutils literal notranslate\">allow_folders</code> 必须有一个被设为 True。</p></li>\n<li><p><strong>fields.E150</strong>： 若``GenericIPAddressField`` 不允许 null 值，那么它也不接受空值，因为空值被保存为 null。</p></li>\n<li><p><strong>fields.E160</strong>: The options <code class=\"docutils literal notranslate\">auto_now</code>, <code class=\"docutils literal notranslate\">auto_now_add</code>, and <code class=\"docutils literal notranslate\">default</code>\nare mutually exclusive. Only one of these options may be present.</p></li>\n<li><p><strong>fields.W161</strong>：默认绑定值。</p></li>\n<li><p><strong>fields.W162</strong>： <code class=\"docutils literal notranslate\">&lt;database&gt;</code> 并不支持在 <code class=\"docutils literal notranslate\">&lt;field data type&gt;</code> 列上创建数据库索引。</p></li>\n<li><p><strong>fields.E170</strong>: <code class=\"docutils literal notranslate\">BinaryField</code>’s <code class=\"docutils literal notranslate\">default</code> cannot be a string. Use bytes\ncontent instead.</p></li>\n<li><p><strong>fields.E900</strong>: <code class=\"docutils literal notranslate\">IPAddressField</code> has been removed except for support in\nhistorical migrations.</p></li>\n<li><p><strong>fields.W900</strong>: <code class=\"docutils literal notranslate\">IPAddressField</code> has been deprecated. Support for it\n(except in historical migrations) will be removed in Django 1.9. <em>This check\nappeared in Django 1.7 and 1.8</em>.</p></li>\n<li><p><strong>fields.W901</strong>: <code class=\"docutils literal notranslate\">CommaSeparatedIntegerField</code> has been deprecated. Support\nfor it (except in historical migrations) will be removed in Django 2.0. <em>This\ncheck appeared in Django 1.10 and 1.11</em>.</p></li>\n<li><p><strong>fields.E901</strong>: <code class=\"docutils literal notranslate\">CommaSeparatedIntegerField</code> is removed except for support\nin historical migrations.</p></li>\n<li><p><strong>fields.W902</strong>: <code class=\"docutils literal notranslate\">FloatRangeField</code> is deprecated and will be removed in\nDjango 3.1.</p></li>\n</ul>\n<section id=\"file-fields\">\n<h4>文件字段<a class=\"heading-anchor\" href=\"#file-fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><strong>fields.E200</strong>: <code class=\"docutils literal notranslate\">unique</code> is not a valid argument for a <code class=\"docutils literal notranslate\">FileField</code>.\n<em>This check is removed in Django 1.11</em>.</p></li>\n<li><p><strong>fields.E201</strong>： <code class=\"docutils literal notranslate\">primary_key</code> 对于 <code class=\"docutils literal notranslate\">FileField</code> 来说不是个有效的参数。</p></li>\n<li><p><strong>fields.E202</strong>： <code class=\"docutils literal notranslate\">FileField</code> 的 <code class=\"docutils literal notranslate\">upload_to</code> 参数必须是个相对路径，而不是一个相对路径。</p></li>\n<li><p><strong>fields.E210</strong>： 不能使用 <code class=\"docutils literal notranslate\">ImageField</code>，因为未安装 Pillow。</p></li>\n</ul>\n</section>\n<section id=\"related-fields\">\n<h4>关联字段<a class=\"heading-anchor\" href=\"#related-fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><strong>fields.E300</strong>: Field defines a relation with model <code class=\"docutils literal notranslate\">&lt;model&gt;</code>, which is\neither not installed, or is abstract.</p></li>\n<li><p><strong>fields.E301</strong>: Field defines a relation with the model <code class=\"docutils literal notranslate\">&lt;model&gt;</code> which\nhas been swapped out.</p></li>\n<li><p><strong>fields.E302</strong>: Accessor for field <code class=\"docutils literal notranslate\">&lt;field name&gt;</code> clashes with field\n<code class=\"docutils literal notranslate\">&lt;field name&gt;</code>.</p></li>\n<li><p><strong>fields.E303</strong>: Reverse query name for field <code class=\"docutils literal notranslate\">&lt;field name&gt;</code> clashes with\nfield <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>.</p></li>\n<li><p><strong>fields.E304</strong>: Field name <code class=\"docutils literal notranslate\">&lt;field name&gt;</code> clashes with accessor for\n<code class=\"docutils literal notranslate\">&lt;field name&gt;</code>.</p></li>\n<li><p><strong>fields.E305</strong>: Field name <code class=\"docutils literal notranslate\">&lt;field name&gt;</code> clashes with reverse query name\nfor <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>.</p></li>\n<li><p><strong>fields.E306</strong>: Related name must be a valid Python identifier or end with\na <code class=\"docutils literal notranslate\">'+'</code>.</p></li>\n<li><p><strong>fields.E307</strong>: The field <code class=\"docutils literal notranslate\">&lt;app label&gt;.&lt;model&gt;.&lt;field name&gt;</code> was declared\nwith a lazy reference to <code class=\"docutils literal notranslate\">&lt;app label&gt;.&lt;model&gt;</code>, but app <code class=\"docutils literal notranslate\">&lt;app label&gt;</code>\nisn't installed or doesn't provide model <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>fields.E308</strong>: Reverse query name <code class=\"docutils literal notranslate\">&lt;related query name&gt;</code> must not end\nwith an underscore.</p></li>\n<li><p><strong>fields.E309</strong>: Reverse query name <code class=\"docutils literal notranslate\">&lt;related query name&gt;</code> must not contain\n<code class=\"docutils literal notranslate\">'__'</code>.</p></li>\n<li><p><strong>fields.E310</strong>: No subset of the fields <code class=\"docutils literal notranslate\">&lt;field1&gt;</code>, <code class=\"docutils literal notranslate\">&lt;field2&gt;</code>, ... on\nmodel <code class=\"docutils literal notranslate\">&lt;model&gt;</code> is unique.</p></li>\n<li><p><strong>fields.E311</strong>: <code class=\"docutils literal notranslate\">&lt;model&gt;</code> must set <code class=\"docutils literal notranslate\">unique=True</code> because it is\nreferenced by a <code class=\"docutils literal notranslate\">ForeignKey</code>.</p></li>\n<li><p><strong>fields.E312</strong>: The <code class=\"docutils literal notranslate\">to_field</code> <code class=\"docutils literal notranslate\">&lt;field name&gt;</code> doesn't exist on the\nrelated model <code class=\"docutils literal notranslate\">&lt;app label&gt;.&lt;model&gt;</code>.</p></li>\n<li><p><strong>fields.E320</strong>: Field specifies <code class=\"docutils literal notranslate\">on_delete=SET_NULL</code>, but cannot be null.</p></li>\n<li><p><strong>fields.E321</strong>: The field specifies <code class=\"docutils literal notranslate\">on_delete=SET_DEFAULT</code>, but has no\ndefault value.</p></li>\n<li><p><strong>fields.E330</strong>: <code class=\"docutils literal notranslate\">ManyToManyField</code>s cannot be unique.</p></li>\n<li><p><strong>fields.E331</strong>: Field specifies a many-to-many relation through model\n<code class=\"docutils literal notranslate\">&lt;model&gt;</code>, which has not been installed.</p></li>\n<li><p><strong>fields.E332</strong>: Many-to-many fields with intermediate tables must not be\nsymmetrical. <em>This check appeared before Django 3.0.</em></p></li>\n<li><p><strong>fields.E333</strong>: The model is used as an intermediate model by <code class=\"docutils literal notranslate\">&lt;model&gt;</code>,\nbut it has more than two foreign keys to <code class=\"docutils literal notranslate\">&lt;model&gt;</code>, which is ambiguous.\nYou must specify which two foreign keys Django should use via the\n<code class=\"docutils literal notranslate\">through_fields</code> keyword argument.</p></li>\n<li><p><strong>fields.E334</strong>: The model is used as an intermediate model by <code class=\"docutils literal notranslate\">&lt;model&gt;</code>,\nbut it has more than one foreign key from <code class=\"docutils literal notranslate\">&lt;model&gt;</code>, which is ambiguous.\nYou must specify which foreign key Django should use via the\n<code class=\"docutils literal notranslate\">through_fields</code> keyword argument.</p></li>\n<li><p><strong>fields.E335</strong>: The model is used as an intermediate model by <code class=\"docutils literal notranslate\">&lt;model&gt;</code>,\nbut it has more than one foreign key to <code class=\"docutils literal notranslate\">&lt;model&gt;</code>, which is ambiguous.\nYou must specify which foreign key Django should use via the\n<code class=\"docutils literal notranslate\">through_fields</code> keyword argument.</p></li>\n<li><p><strong>fields.E336</strong>: The model is used as an intermediary model by <code class=\"docutils literal notranslate\">&lt;model&gt;</code>,\nbut it does not have foreign key to <code class=\"docutils literal notranslate\">&lt;model&gt;</code> or <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>fields.E337</strong>: Field specifies <code class=\"docutils literal notranslate\">through_fields</code> but does not provide the\nnames of the two link fields that should be used for the relation through\n<code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>fields.E338</strong>: The intermediary model <code class=\"docutils literal notranslate\">&lt;through model&gt;</code> has no field\n<code class=\"docutils literal notranslate\">&lt;field name&gt;</code>.</p></li>\n<li><p><strong>fields.E339</strong>: <code class=\"docutils literal notranslate\">&lt;model&gt;.&lt;field name&gt;</code> is not a foreign key to <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>fields.E340</strong>: The field's intermediary table <code class=\"docutils literal notranslate\">&lt;table name&gt;</code> clashes with\nthe table name of <code class=\"docutils literal notranslate\">&lt;model&gt;</code>/<code class=\"docutils literal notranslate\">&lt;model&gt;.&lt;field name&gt;</code>.</p></li>\n<li><p><strong>fields.W340</strong>: <code class=\"docutils literal notranslate\">null</code> has no effect on <code class=\"docutils literal notranslate\">ManyToManyField</code>.</p></li>\n<li><p><strong>fields.W341</strong>: <code class=\"docutils literal notranslate\">ManyToManyField</code> does not support <code class=\"docutils literal notranslate\">validators</code>.</p></li>\n<li><p><strong>fields.W342</strong>: Setting <code class=\"docutils literal notranslate\">unique=True</code> on a <code class=\"docutils literal notranslate\">ForeignKey</code> has the same\neffect as using a <code class=\"docutils literal notranslate\">OneToOneField</code>.</p></li>\n<li><p><strong>fields.W343</strong>: <code class=\"docutils literal notranslate\">limit_choices_to</code> has no effect on <code class=\"docutils literal notranslate\">ManyToManyField</code>\nwith a <code class=\"docutils literal notranslate\">through</code> model.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"models\">\n<h3>模型<a class=\"heading-anchor\" href=\"#models\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<ul class=\"simple\">\n<li><p><strong>models.E001</strong>： <code class=\"docutils literal notranslate\">&lt;swappable&gt;</code> 不是表单 <code class=\"docutils literal notranslate\">app_label.app_name</code>。</p></li>\n<li><p><strong>models.E002</strong>: <code class=\"docutils literal notranslate\">&lt;SETTING&gt;</code> references <code class=\"docutils literal notranslate\">&lt;model&gt;</code>, which has not been\ninstalled, or is abstract.</p></li>\n<li><p><strong>models.E003</strong>: The model has two identical many-to-many relations through\nthe intermediate model <code class=\"docutils literal notranslate\">&lt;app_label&gt;.&lt;model&gt;</code>.</p></li>\n<li><p><strong>models.E004</strong>: <code class=\"docutils literal notranslate\">id</code> can only be used as a field name if the field also\nsets <code class=\"docutils literal notranslate\">primary_key=True</code>.</p></li>\n<li><p><strong>models.E005</strong>: The field <code class=\"docutils literal notranslate\">&lt;field name&gt;</code> from parent model <code class=\"docutils literal notranslate\">&lt;model&gt;</code>\nclashes with the field <code class=\"docutils literal notranslate\">&lt;field name&gt;</code> from parent model <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>models.E006</strong>：与另一个模型 <code class=\"docutils literal notranslate\">&lt;model&gt;</code> 的字段 <code class=\"docutils literal notranslate\">&lt;field name&gt;</code> 冲突的字段。</p></li>\n<li><p><strong>models.E007</strong>： 列名 <code class=\"docutils literal notranslate\">&lt;column name&gt;</code> 被其它字段使用的字段 <code class=\"docutils literal notranslate\">&lt;field name&gt;</code> 。</p></li>\n<li><p><strong>models.E008</strong>： <code class=\"docutils literal notranslate\">index_together</code> 必须是个列表或元组。</p></li>\n<li><p><strong>models.E009</strong>： 所有 <code class=\"docutils literal notranslate\">index_together</code> 元素都必须是列表或元组。</p></li>\n<li><p><strong>models.E010</strong>： <code class=\"docutils literal notranslate\">unique_together</code> 必须是个列表或元组。</p></li>\n<li><p><strong>models.E011</strong>： 所有 <code class=\"docutils literal notranslate\">unique_together</code> 元素都必须是列表或元组。</p></li>\n<li><p><strong>models.E012</strong>： <code class=\"docutils literal notranslate\">indexes/index_together/unique_together</code> 指向了不存在的字段 <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>。</p></li>\n<li><p><strong>models.E013</strong>： <code class=\"docutils literal notranslate\">indexes/index_together/unique_together</code> 指向一个 <code class=\"docutils literal notranslate\">ManyToManyField</code> <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>，但此选项不支持 <code class=\"docutils literal notranslate\">ManyToManyField</code>。</p></li>\n<li><p><strong>models.E014</strong>： <code class=\"docutils literal notranslate\">ordering</code> 必须是个元组或列表（即便你只想按照一个字段进行排序）。</p></li>\n<li><p><strong>models.E015</strong>: <code class=\"docutils literal notranslate\">ordering</code> refers to the nonexistent field, related field,\nor lookup <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>.</p></li>\n<li><p><strong>models.E016</strong>: <code class=\"docutils literal notranslate\">indexes/index_together/unique_together</code> refers to field\n<code class=\"docutils literal notranslate\">&lt;field_name&gt;</code> which is not local to model <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>models.E017</strong>: Proxy model <code class=\"docutils literal notranslate\">&lt;model&gt;</code> contains model fields.</p></li>\n<li><p><strong>models.E018</strong>: Autogenerated column name too long for field <code class=\"docutils literal notranslate\">&lt;field&gt;</code>.\nMaximum length is <code class=\"docutils literal notranslate\">&lt;maximum length&gt;</code> for database <code class=\"docutils literal notranslate\">&lt;alias&gt;</code>.</p></li>\n<li><p><strong>models.E019</strong>: Autogenerated column name too long for M2M field\n<code class=\"docutils literal notranslate\">&lt;M2M field&gt;</code>. Maximum length is <code class=\"docutils literal notranslate\">&lt;maximum length&gt;</code> for database\n<code class=\"docutils literal notranslate\">&lt;alias&gt;</code>.</p></li>\n<li><p><strong>models.E020</strong>: The <code class=\"docutils literal notranslate\">&lt;model&gt;.check()</code> class method is currently overridden.</p></li>\n<li><p><strong>models.E021</strong>: <code class=\"docutils literal notranslate\">ordering</code> and <code class=\"docutils literal notranslate\">order_with_respect_to</code> cannot be used\ntogether.</p></li>\n<li><p><strong>models.E022</strong>: <code class=\"docutils literal notranslate\">&lt;function&gt;</code> contains a lazy reference to\n<code class=\"docutils literal notranslate\">&lt;app label&gt;.&lt;model&gt;</code>, but app <code class=\"docutils literal notranslate\">&lt;app label&gt;</code> isn't installed or\ndoesn't provide model <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>models.E023</strong>: The model name <code class=\"docutils literal notranslate\">&lt;model&gt;</code> cannot start or end with an\nunderscore as it collides with the query lookup syntax.</p></li>\n<li><p><strong>models.E024</strong>: The model name <code class=\"docutils literal notranslate\">&lt;model&gt;</code> cannot contain double underscores\nas it collides with the query lookup syntax.</p></li>\n<li><p><strong>models.E025</strong>: The property <code class=\"docutils literal notranslate\">&lt;property name&gt;</code> clashes with a related\nfield accessor.</p></li>\n<li><p><strong>models.E026</strong>: The model cannot have more than one field with\n<code class=\"docutils literal notranslate\">primary_key=True</code>.</p></li>\n<li><p><strong>models.W027</strong>: <code class=\"docutils literal notranslate\">&lt;database&gt;</code> does not support check constraints.</p></li>\n<li><p><strong>models.E028</strong>: <code class=\"docutils literal notranslate\">db_table</code> <code class=\"docutils literal notranslate\">&lt;db_table&gt;</code> is used by multiple models:\n<code class=\"docutils literal notranslate\">&lt;model list&gt;</code>.</p></li>\n<li><p><strong>models.E029</strong>: index name <code class=\"docutils literal notranslate\">&lt;index&gt;</code> is not unique for model <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>models.E030</strong>: index name <code class=\"docutils literal notranslate\">&lt;index&gt;</code> is not unique amongst models:\n<code class=\"docutils literal notranslate\">&lt;model list&gt;</code>.</p></li>\n<li><p><strong>models.E031</strong>: constraint name <code class=\"docutils literal notranslate\">&lt;constraint&gt;</code> is not unique for model\n<code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>models.E032</strong>: constraint name <code class=\"docutils literal notranslate\">&lt;constraint&gt;</code> is not unique amongst\nmodels: <code class=\"docutils literal notranslate\">&lt;model list&gt;</code>.</p></li>\n<li><p><strong>models.E033</strong>: The index name <code class=\"docutils literal notranslate\">&lt;index&gt;</code> cannot start with an underscore\nor a number.</p></li>\n<li><p><strong>models.E034</strong>: The index name <code class=\"docutils literal notranslate\">&lt;index&gt;</code> cannot be longer than\n<code class=\"docutils literal notranslate\">&lt;max_length&gt;</code> characters.</p></li>\n<li><p><strong>models.W035</strong>: <code class=\"docutils literal notranslate\">db_table</code> <code class=\"docutils literal notranslate\">&lt;db_table&gt;</code> is used by multiple models:\n<code class=\"docutils literal notranslate\">&lt;model list&gt;</code>.</p></li>\n</ul>\n</section>\n<section id=\"security\">\n<h3>安全<a class=\"heading-anchor\" href=\"#security\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The security checks do not make your site secure. They do not audit code, do\nintrusion detection, or do anything particularly complex. Rather, they help\nperform an automated, low-hanging-fruit checklist, that can help you to improve\nyour site's security.</p>\n<p>Some of these checks may not be appropriate for your particular deployment\nconfiguration. For instance, if you do your HTTP to HTTPS redirection in a load\nbalancer, it'd be irritating to be constantly warned about not having enabled\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_SSL_REDIRECT\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_SSL_REDIRECT</code></a>. Use <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SILENCED_SYSTEM_CHECKS\"><code class=\"xref std std-setting docutils literal notranslate\">SILENCED_SYSTEM_CHECKS</code></a> to\nsilence unneeded checks.</p>\n<p>The following checks are run if you use the <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/django-admin/#cmdoption-check-deploy\"><code class=\"xref std std-option docutils literal notranslate\">check --deploy</code></a> option:</p>\n<ul class=\"simple\">\n<li><p><strong>security.W001</strong>: You do not have\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/middleware/#django.middleware.security.SecurityMiddleware\" title=\"django.middleware.security.SecurityMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">django.middleware.security.SecurityMiddleware</code></a> in your\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</code></a> so the <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_HSTS_SECONDS\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_HSTS_SECONDS</code></a>,\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_CONTENT_TYPE_NOSNIFF\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_CONTENT_TYPE_NOSNIFF</code></a>, <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_BROWSER_XSS_FILTER\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_BROWSER_XSS_FILTER</code></a>,\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_REFERRER_POLICY\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_REFERRER_POLICY</code></a>, and <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_SSL_REDIRECT\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_SSL_REDIRECT</code></a>\nsettings will have no effect.</p></li>\n<li><p><strong>security.W002</strong>: You do not have\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/middleware/#django.middleware.clickjacking.XFrameOptionsMiddleware\" title=\"django.middleware.clickjacking.XFrameOptionsMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">django.middleware.clickjacking.XFrameOptionsMiddleware</code></a> in your\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</code></a>, so your pages will not be served with an\n<code class=\"docutils literal notranslate\">'x-frame-options'</code> header. Unless there is a good reason for your\nsite to be served in a frame, you should consider enabling this\nheader to help prevent clickjacking attacks.</p></li>\n<li><p><strong>security.W003</strong>: You don't appear to be using Django's built-in cross-site\nrequest forgery protection via the middleware\n(<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/middleware/#django.middleware.csrf.CsrfViewMiddleware\" title=\"django.middleware.csrf.CsrfViewMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">django.middleware.csrf.CsrfViewMiddleware</code></a> is not in your\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</code></a>). Enabling the middleware is the safest\napproach to ensure you don't leave any holes.</p></li>\n<li><p><strong>security.W004</strong>: You have not set a value for the\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_HSTS_SECONDS\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_HSTS_SECONDS</code></a> setting. If your entire site is served only\nover SSL, you may want to consider setting a value and enabling <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/middleware/#http-strict-transport-security\"><span class=\"std std-ref\">HTTP\nStrict Transport Security</span></a>. Be sure to read\nthe documentation first; enabling HSTS carelessly can cause serious,\nirreversible problems.</p></li>\n<li><p><strong>security.W005</strong>: You have not set the\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_HSTS_INCLUDE_SUBDOMAINS\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_HSTS_INCLUDE_SUBDOMAINS</code></a> setting to <code class=\"docutils literal notranslate\">True</code>. Without this,\nyour site is potentially vulnerable to attack via an insecure connection to a\nsubdomain. Only set this to <code class=\"docutils literal notranslate\">True</code> if you are certain that all subdomains of\nyour domain should be served exclusively via SSL.</p></li>\n<li><p><strong>security.W006</strong>: Your <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_CONTENT_TYPE_NOSNIFF\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_CONTENT_TYPE_NOSNIFF</code></a> setting is not\nset to <code class=\"docutils literal notranslate\">True</code>, so your pages will not be served with an\n<code class=\"docutils literal notranslate\">'X-Content-Type-Options: nosniff'</code> header. You should consider enabling\nthis header to prevent the browser from identifying content types incorrectly.</p></li>\n<li><p><strong>security.W007</strong>: Your <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_BROWSER_XSS_FILTER\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_BROWSER_XSS_FILTER</code></a> setting is not\nset to <code class=\"docutils literal notranslate\">True</code>, so your pages will not be served with an\n<code class=\"docutils literal notranslate\">'X-XSS-Protection: 1; mode=block'</code> header. You should consider enabling\nthis header to activate the browser's XSS filtering and help prevent XSS\nattacks. <em>This check is removed in Django 3.0 as the</em> <code class=\"docutils literal notranslate\">X-XSS-Protection</code>\n<em>header is no longer honored by modern browsers.</em></p></li>\n<li><p><strong>security.W008</strong>: Your <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_SSL_REDIRECT\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_SSL_REDIRECT</code></a> setting is not set to\n<code class=\"docutils literal notranslate\">True</code>. Unless your site should be available over both SSL and non-SSL\nconnections, you may want to either set this setting to <code class=\"docutils literal notranslate\">True</code> or configure\na load balancer or reverse-proxy server  to redirect all connections to HTTPS.</p></li>\n<li><p><strong>security.W009</strong>: Your <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECRET_KEY\"><code class=\"xref std std-setting docutils literal notranslate\">SECRET_KEY</code></a> has less than 50 characters or\nless than 5 unique characters. Please generate a long and random\n<code class=\"docutils literal notranslate\">SECRET_KEY</code>, otherwise many of Django's security-critical features will be\nvulnerable to attack.</p></li>\n<li><p><strong>security.W010</strong>: You have <a class=\"reference internal\" href=\"/zh-hans/3.0/topics/http/sessions/#module-django.contrib.sessions\" title=\"django.contrib.sessions: Provides session management for Django projects.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.sessions</code></a> in your\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> but you have not set\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SESSION_COOKIE_SECURE\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_COOKIE_SECURE</code></a> to <code class=\"docutils literal notranslate\">True</code>. Using a secure-only session\ncookie makes it more difficult for network traffic sniffers to hijack user\nsessions.</p></li>\n<li><p><strong>security.W011</strong>: You have\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/middleware/#django.contrib.sessions.middleware.SessionMiddleware\" title=\"django.contrib.sessions.middleware.SessionMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">django.contrib.sessions.middleware.SessionMiddleware</code></a> in your\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</code></a>, but you have not set <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SESSION_COOKIE_SECURE\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_COOKIE_SECURE</code></a>\nto <code class=\"docutils literal notranslate\">True</code>. Using a secure-only session cookie makes it more difficult for\nnetwork traffic sniffers to hijack user sessions.</p></li>\n<li><p><strong>security.W012</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SESSION_COOKIE_SECURE\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_COOKIE_SECURE</code></a> is not set to <code class=\"docutils literal notranslate\">True</code>.\nUsing a secure-only session cookie makes it more difficult for network traffic\nsniffers to hijack user sessions.</p></li>\n<li><p><strong>security.W013</strong>: You have <a class=\"reference internal\" href=\"/zh-hans/3.0/topics/http/sessions/#module-django.contrib.sessions\" title=\"django.contrib.sessions: Provides session management for Django projects.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.sessions</code></a> in your\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a>, but you have not set\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SESSION_COOKIE_HTTPONLY\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_COOKIE_HTTPONLY</code></a> to <code class=\"docutils literal notranslate\">True</code>. Using an <code class=\"docutils literal notranslate\">HttpOnly</code> session\ncookie makes it more difficult for cross-site scripting attacks to hijack user\nsessions.</p></li>\n<li><p><strong>security.W014</strong>: You have\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/middleware/#django.contrib.sessions.middleware.SessionMiddleware\" title=\"django.contrib.sessions.middleware.SessionMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">django.contrib.sessions.middleware.SessionMiddleware</code></a> in your\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</code></a>, but you have not set <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SESSION_COOKIE_HTTPONLY\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_COOKIE_HTTPONLY</code></a>\nto <code class=\"docutils literal notranslate\">True</code>. Using an <code class=\"docutils literal notranslate\">HttpOnly</code> session cookie makes it more difficult for\ncross-site scripting attacks to hijack user sessions.</p></li>\n<li><p><strong>security.W015</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SESSION_COOKIE_HTTPONLY\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_COOKIE_HTTPONLY</code></a> is not set to <code class=\"docutils literal notranslate\">True</code>.\nUsing an <code class=\"docutils literal notranslate\">HttpOnly</code> session cookie makes it more difficult for cross-site\nscripting attacks to hijack user sessions.</p></li>\n<li><p><strong>security.W016</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-CSRF_COOKIE_SECURE\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_COOKIE_SECURE</code></a> is not set to <code class=\"docutils literal notranslate\">True</code>.\nUsing a secure-only CSRF cookie makes it more difficult for network traffic\nsniffers to steal the CSRF token.</p></li>\n<li><p><strong>security.W017</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-CSRF_COOKIE_HTTPONLY\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_COOKIE_HTTPONLY</code></a> is not set to <code class=\"docutils literal notranslate\">True</code>.\nUsing an <code class=\"docutils literal notranslate\">HttpOnly</code> CSRF cookie makes it more difficult for cross-site\nscripting attacks to steal the CSRF token. <em>This check is removed in Django\n1.11 as the</em> <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-CSRF_COOKIE_HTTPONLY\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_COOKIE_HTTPONLY</code></a> <em>setting offers no practical\nbenefit.</em></p></li>\n<li><p><strong>security.W018</strong>: You should not have <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> set to <code class=\"docutils literal notranslate\">True</code> in\ndeployment.</p></li>\n<li><p><strong>security.W019</strong>: You have\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/middleware/#django.middleware.clickjacking.XFrameOptionsMiddleware\" title=\"django.middleware.clickjacking.XFrameOptionsMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">django.middleware.clickjacking.XFrameOptionsMiddleware</code></a> in your\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</code></a>, but <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-X_FRAME_OPTIONS\"><code class=\"xref std std-setting docutils literal notranslate\">X_FRAME_OPTIONS</code></a> is not set to\n<code class=\"docutils literal notranslate\">'DENY'</code>. Unless there is a good reason for your site to serve other parts\nof itself in a frame, you should change it to <code class=\"docutils literal notranslate\">'DENY'</code>.</p></li>\n<li><p><strong>security.W020</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-ALLOWED_HOSTS\"><code class=\"xref std std-setting docutils literal notranslate\">ALLOWED_HOSTS</code></a> must not be empty in deployment.</p></li>\n<li><p><strong>security.W021</strong>: You have not set the\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_HSTS_PRELOAD\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_HSTS_PRELOAD</code></a> setting to <code class=\"docutils literal notranslate\">True</code>. Without this, your site\ncannot be submitted to the browser preload list.</p></li>\n<li><p><strong>security.W022</strong>: You have not set the <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_REFERRER_POLICY\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_REFERRER_POLICY</code></a>\nsetting. Without this, your site will not send a Referrer-Policy header. You\nshould consider enabling this header to protect user privacy.</p></li>\n<li><p><strong>security.E023</strong>: You have set the <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-SECURE_REFERRER_POLICY\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_REFERRER_POLICY</code></a> setting\nto an invalid value.</p></li>\n</ul>\n</section>\n<section id=\"signals\">\n<h3>信号<a class=\"heading-anchor\" href=\"#signals\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<ul class=\"simple\">\n<li><p><strong>signals.E001</strong>: <code class=\"docutils literal notranslate\">&lt;handler&gt;</code> was connected to the <code class=\"docutils literal notranslate\">&lt;signal&gt;</code> signal with\na lazy reference to the sender <code class=\"docutils literal notranslate\">&lt;app label&gt;.&lt;model&gt;</code>, but app <code class=\"docutils literal notranslate\">&lt;app label&gt;</code>\nisn't installed or doesn't provide model <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n</ul>\n</section>\n<section id=\"templates\">\n<h3>模板<a class=\"heading-anchor\" href=\"#templates\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The following checks verify that your <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-TEMPLATES\"><code class=\"xref std std-setting docutils literal notranslate\">TEMPLATES</code></a> setting is correctly\nconfigured:</p>\n<ul class=\"simple\">\n<li><p><strong>templates.E001</strong>: You have <code class=\"docutils literal notranslate\">'APP_DIRS': True</code> in your\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-TEMPLATES\"><code class=\"xref std std-setting docutils literal notranslate\">TEMPLATES</code></a> but also specify <code class=\"docutils literal notranslate\">'loaders'</code> in <code class=\"docutils literal notranslate\">OPTIONS</code>. Either\nremove <code class=\"docutils literal notranslate\">APP_DIRS</code> or remove the <code class=\"docutils literal notranslate\">'loaders'</code> option.</p></li>\n<li><p><strong>templates.E002</strong>: <code class=\"docutils literal notranslate\">string_if_invalid</code> in <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-TEMPLATES\"><code class=\"xref std std-setting docutils literal notranslate\">TEMPLATES</code></a>\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-TEMPLATES-OPTIONS\"><code class=\"xref std std-setting docutils literal notranslate\">OPTIONS</code></a> must be a string but got: <code class=\"docutils literal notranslate\">{value}</code>\n(<code class=\"docutils literal notranslate\">{type}</code>).</p></li>\n</ul>\n</section>\n<section id=\"translation\">\n<h3>翻译<a class=\"heading-anchor\" href=\"#translation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The following checks are performed on your translation configuration:</p>\n<ul class=\"simple\">\n<li><p><strong>translation.E001</strong>: You have provided an invalid value for the\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-LANGUAGE_CODE\"><code class=\"xref std std-setting docutils literal notranslate\">LANGUAGE_CODE</code></a> setting: <code class=\"docutils literal notranslate\">&lt;value&gt;</code>.</p></li>\n<li><p><strong>translation.E002</strong>: You have provided an invalid language code in the\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-LANGUAGES\"><code class=\"xref std std-setting docutils literal notranslate\">LANGUAGES</code></a> setting: <code class=\"docutils literal notranslate\">&lt;value&gt;</code>.</p></li>\n<li><p><strong>translation.E003</strong>: You have provided an invalid language code in the\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-LANGUAGES_BIDI\"><code class=\"xref std std-setting docutils literal notranslate\">LANGUAGES_BIDI</code></a> setting: <code class=\"docutils literal notranslate\">&lt;value&gt;</code>.</p></li>\n<li><p><strong>translation.E004</strong>: You have provided a value for the\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-LANGUAGE_CODE\"><code class=\"xref std std-setting docutils literal notranslate\">LANGUAGE_CODE</code></a> setting that is not in the <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-LANGUAGES\"><code class=\"xref std std-setting docutils literal notranslate\">LANGUAGES</code></a>\nsetting.</p></li>\n</ul>\n</section>\n<section id=\"urls\">\n<h3>URLs<a class=\"heading-anchor\" href=\"#urls\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>以下检查项针对你的 URL 配置执行：</p>\n<ul class=\"simple\">\n<li><p><strong>urls.W001</strong>: Your URL pattern <code class=\"docutils literal notranslate\">&lt;pattern&gt;</code> uses\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/urls/#django.urls.include\" title=\"django.urls.include\"><code class=\"xref py py-func docutils literal notranslate\">include()</code></a> with a <code class=\"docutils literal notranslate\">route</code> ending with a <code class=\"docutils literal notranslate\">$</code>. Remove the\ndollar from the <code class=\"docutils literal notranslate\">route</code> to avoid problems including URLs.</p></li>\n<li><p><strong>urls.W002</strong>: Your URL pattern <code class=\"docutils literal notranslate\">&lt;pattern&gt;</code> has a <code class=\"docutils literal notranslate\">route</code> beginning with\na <code class=\"docutils literal notranslate\">/</code>. Remove this slash as it is unnecessary. If this pattern is targeted\nin an <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/urls/#django.urls.include\" title=\"django.urls.include\"><code class=\"xref py py-func docutils literal notranslate\">include()</code></a>, ensure the <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/urls/#django.urls.include\" title=\"django.urls.include\"><code class=\"xref py py-func docutils literal notranslate\">include()</code></a>\npattern has a trailing <code class=\"docutils literal notranslate\">/</code>.</p></li>\n<li><p><strong>urls.W003</strong>: Your URL pattern <code class=\"docutils literal notranslate\">&lt;pattern&gt;</code> has a <code class=\"docutils literal notranslate\">name</code>\nincluding a <code class=\"docutils literal notranslate\">:</code>. Remove the colon, to avoid ambiguous namespace\nreferences.</p></li>\n<li><p><strong>urls.E004</strong>: Your URL pattern <code class=\"docutils literal notranslate\">&lt;pattern&gt;</code> is invalid. Ensure that\n<code class=\"docutils literal notranslate\">urlpatterns</code> is a list of <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/urls/#django.urls.path\" title=\"django.urls.path\"><code class=\"xref py py-func docutils literal notranslate\">path()</code></a> and/or\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/urls/#django.urls.re_path\" title=\"django.urls.re_path\"><code class=\"xref py py-func docutils literal notranslate\">re_path()</code></a> instances.</p></li>\n<li><p><strong>urls.W005</strong>: URL namespace <code class=\"docutils literal notranslate\">&lt;namespace&gt;</code> isn't unique. You may not be\nable to reverse all URLs in this namespace.</p></li>\n<li><p><strong>urls.E006</strong>: The <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-MEDIA_URL\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_URL</code></a>/ <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</code></a> setting must\nend with a slash.</p></li>\n<li><p><strong>urls.E007</strong>: The custom <code class=\"docutils literal notranslate\">handlerXXX</code> view <code class=\"docutils literal notranslate\">'path.to.view'</code> does not\ntake the correct number of arguments (…).</p></li>\n<li><p><strong>urls.E008</strong>: The custom <code class=\"docutils literal notranslate\">handlerXXX</code> view <code class=\"docutils literal notranslate\">'path.to.view'</code> could not be\nimported.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"contrib-app-checks\">\n<h2><code class=\"docutils literal notranslate\">contrib</code> 应用检查<a class=\"heading-anchor\" href=\"#contrib-app-checks\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"admin\">\n<h3><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></h3>\n<p>后台检查项均作为 <code class=\"docutils literal notranslate\">admin</code> 标签的一部分执行。</p>\n<p>以下检查项在每个通过后台站点注册的 <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin\" title=\"django.contrib.admin.ModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">ModelAdmin</code></a> （或其子类）上执行。</p>\n<ul class=\"simple\">\n<li><p><strong>admin.E001</strong>： <code class=\"docutils literal notranslate\">raw_id_fields</code> 的值必须是个列表或元组。</p></li>\n<li><p><strong>admin.E002</strong>： <code class=\"docutils literal notranslate\">raw_id_fields[n]</code> 的值指向 <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>，它并不是 <code class=\"docutils literal notranslate\">&lt;model&gt;</code> 的属性。</p></li>\n<li><p><strong>admin.E003</strong>： <code class=\"docutils literal notranslate\">raw_id_fields[n]</code> 的值必须是个外键或一个多对多字段。</p></li>\n<li><p><strong>admin.E004</strong>： <code class=\"docutils literal notranslate\">fields</code> 的值必须是列表或元组。</p></li>\n<li><p><strong>admin.E005</strong>： <code class=\"docutils literal notranslate\">fieldsets</code> 和 <code class=\"docutils literal notranslate\">fields</code> 都是定制的。</p></li>\n<li><p><strong>admin.E006</strong>： <code class=\"docutils literal notranslate\">fields</code> 的值包含了重复字段。</p></li>\n<li><p><strong>admin.E007</strong>： <code class=\"docutils literal notranslate\">fieldsets</code> 的值必须是个列表或元组。</p></li>\n<li><p><strong>admin.E008</strong>： <code class=\"docutils literal notranslate\">fieldsets[n]</code> 的值必须是个列表或元组。</p></li>\n<li><p><strong>admin.E009</strong>： <code class=\"docutils literal notranslate\">fieldsets[n]</code> 的值的长度必须是 2。</p></li>\n<li><p><strong>admin.E010</strong>： <code class=\"docutils literal notranslate\">fieldsets[n][1]</code> 的值必须是个字典。</p></li>\n<li><p><strong>admin.E011</strong>： <code class=\"docutils literal notranslate\">fieldsets[n][1]</code> 的值必须包含键 <code class=\"docutils literal notranslate\">fields</code>。</p></li>\n<li><p><strong>admin.E012</strong>： <code class=\"docutils literal notranslate\">fieldsets[n][1]</code> 中有重复字段。</p></li>\n<li><p><strong>admin.E013</strong>: <code class=\"docutils literal notranslate\">fields[n]/fieldsets[n][m]</code> cannot include the\n<code class=\"docutils literal notranslate\">ManyToManyField</code> <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>, because that field manually specifies a\nrelationship model.</p></li>\n<li><p><strong>admin.E014</strong>： <code class=\"docutils literal notranslate\">exclude</code> 的值必须是个列表或元组。</p></li>\n<li><p><strong>admin.E015</strong>： <code class=\"docutils literal notranslate\">exclude</code> 的值必须包含重复字段。</p></li>\n<li><p><strong>admin.E016</strong>： <code class=\"docutils literal notranslate\">form</code> 的值必须继承自 <code class=\"docutils literal notranslate\">BaseModelForm</code>。</p></li>\n<li><p><strong>admin.E017</strong>： <code class=\"docutils literal notranslate\">filter_vertical</code> 的值必须是个列表或元组。</p></li>\n<li><p><strong>admin.E018</strong>： <code class=\"docutils literal notranslate\">filter_horizontal</code> 的值必须是个列表或元组。</p></li>\n<li><p><strong>admin.E019</strong>: The value of <code class=\"docutils literal notranslate\">filter_vertical[n]/filter_vertical[n]</code> refers\nto <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>, which is not an attribute of <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E020</strong>: The value of <code class=\"docutils literal notranslate\">filter_vertical[n]/filter_vertical[n]</code> must\nbe a many-to-many field.</p></li>\n<li><p><strong>admin.E021</strong>: The value of <code class=\"docutils literal notranslate\">radio_fields</code> must be a dictionary.</p></li>\n<li><p><strong>admin.E022</strong>: The value of <code class=\"docutils literal notranslate\">radio_fields</code> refers to <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>,\nwhich is not an attribute of <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E023</strong>: The value of <code class=\"docutils literal notranslate\">radio_fields</code> refers to <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>,\nwhich is not a <code class=\"docutils literal notranslate\">ForeignKey</code>, and does not have a <code class=\"docutils literal notranslate\">choices</code> definition.</p></li>\n<li><p><strong>admin.E024</strong>: The value of <code class=\"docutils literal notranslate\">radio_fields[&lt;field name&gt;]</code> must be either\n<code class=\"docutils literal notranslate\">admin.HORIZONTAL</code> or <code class=\"docutils literal notranslate\">admin.VERTICAL</code>.</p></li>\n<li><p><strong>admin.E025</strong>: The value of <code class=\"docutils literal notranslate\">view_on_site</code> must be either a callable or a\nboolean value.</p></li>\n<li><p><strong>admin.E026</strong>: The value of <code class=\"docutils literal notranslate\">prepopulated_fields</code> must be a dictionary.</p></li>\n<li><p><strong>admin.E027</strong>: The value of <code class=\"docutils literal notranslate\">prepopulated_fields</code> refers to\n<code class=\"docutils literal notranslate\">&lt;field name&gt;</code>, which is not an attribute of <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E028</strong>: The value of <code class=\"docutils literal notranslate\">prepopulated_fields</code> refers to\n<code class=\"docutils literal notranslate\">&lt;field name&gt;</code>, which must not be a <code class=\"docutils literal notranslate\">DateTimeField</code>, a <code class=\"docutils literal notranslate\">ForeignKey</code>,\na <code class=\"docutils literal notranslate\">OneToOneField</code>, or a <code class=\"docutils literal notranslate\">ManyToManyField</code> field.</p></li>\n<li><p><strong>admin.E029</strong>: The value of <code class=\"docutils literal notranslate\">prepopulated_fields[&lt;field name&gt;]</code> must be a\nlist or tuple.</p></li>\n<li><p><strong>admin.E030</strong>: The value of <code class=\"docutils literal notranslate\">prepopulated_fields</code> refers to\n<code class=\"docutils literal notranslate\">&lt;field name&gt;</code>, which is not an attribute of <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E031</strong>: The value of <code class=\"docutils literal notranslate\">ordering</code> must be a list or tuple.</p></li>\n<li><p><strong>admin.E032</strong>: The value of <code class=\"docutils literal notranslate\">ordering</code> has the random ordering marker\n<code class=\"docutils literal notranslate\">?</code>, but contains other fields as well.</p></li>\n<li><p><strong>admin.E033</strong>: The value of <code class=\"docutils literal notranslate\">ordering</code> refers to <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>, which\nis not an attribute of <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E034</strong>: The value of <code class=\"docutils literal notranslate\">readonly_fields</code> must be a list or tuple.</p></li>\n<li><p><strong>admin.E035</strong>: The value of <code class=\"docutils literal notranslate\">readonly_fields[n]</code> is not a callable, an\nattribute of <code class=\"docutils literal notranslate\">&lt;ModelAdmin class&gt;</code>, or an attribute of <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E036</strong>: The value of <code class=\"docutils literal notranslate\">autocomplete_fields</code> must be a list or tuple.</p></li>\n<li><p><strong>admin.E037</strong>: The value of <code class=\"docutils literal notranslate\">autocomplete_fields[n]</code> refers to\n<code class=\"docutils literal notranslate\">&lt;field name&gt;</code>, which is not an attribute of <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E038</strong>: The value of <code class=\"docutils literal notranslate\">autocomplete_fields[n]</code> must be a foreign\nkey or a many-to-many field.</p></li>\n<li><p><strong>admin.E039</strong>: An admin for model <code class=\"docutils literal notranslate\">&lt;model&gt;</code> has to be registered to be\nreferenced by <code class=\"docutils literal notranslate\">&lt;modeladmin&gt;.autocomplete_fields</code>.</p></li>\n<li><p><strong>admin.E040</strong>: <code class=\"docutils literal notranslate\">&lt;modeladmin&gt;</code> must define <code class=\"docutils literal notranslate\">search_fields</code>, because\nit's referenced by <code class=\"docutils literal notranslate\">&lt;other_modeladmin&gt;.autocomplete_fields</code>.</p></li>\n</ul>\n<section id=\"modeladmin\">\n<h4><code class=\"docutils literal notranslate\">ModelAdmin</code><a class=\"heading-anchor\" href=\"#modeladmin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>The following checks are performed on any\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin\" title=\"django.contrib.admin.ModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">ModelAdmin</code></a> that is registered\nwith the admin site:</p>\n<ul class=\"simple\">\n<li><p><strong>admin.E101</strong>： <code class=\"docutils literal notranslate\">save_as</code> 的值必须是个布尔值。</p></li>\n<li><p><strong>admin.E102</strong>： <code class=\"docutils literal notranslate\">save_on_top</code> 的值必须是个布尔值。</p></li>\n<li><p><strong>admin.E103</strong>： <code class=\"docutils literal notranslate\">inlines</code> 的值必须是个列表或元组。</p></li>\n<li><p><strong>admin.E104</strong>： <code class=\"docutils literal notranslate\">&lt;InlineModelAdmin class&gt;</code> 必须继承自 <code class=\"docutils literal notranslate\">InlineModelAdmin</code>。</p></li>\n<li><p><strong>admin.E105</strong>： <code class=\"docutils literal notranslate\">&lt;InlineModelAdmin class&gt;</code> 必须有个 <code class=\"docutils literal notranslate\">model</code> 属性。</p></li>\n<li><p><strong>admin.E106</strong>： <code class=\"docutils literal notranslate\">&lt;InlineModelAdmin class&gt;.model</code> 的值必须是个 <code class=\"docutils literal notranslate\">Model</code>。</p></li>\n<li><p><strong>admin.E107</strong>： <code class=\"docutils literal notranslate\">list_display</code> 的值必须是个列表或元组。</p></li>\n<li><p><strong>admin.E108</strong>: The value of <code class=\"docutils literal notranslate\">list_display[n]</code> refers to <code class=\"docutils literal notranslate\">&lt;label&gt;</code>,\nwhich is not a callable, an attribute of <code class=\"docutils literal notranslate\">&lt;ModelAdmin class&gt;</code>, or an\nattribute or method on <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E109</strong>： <code class=\"docutils literal notranslate\">list_display[n]</code> 的值绝对不能是个 <code class=\"docutils literal notranslate\">ManyToManyField</code> 字段。</p></li>\n<li><p><strong>admin.E110</strong>: The value of <code class=\"docutils literal notranslate\">list_display_links</code> must be a list, a tuple,\nor <code class=\"docutils literal notranslate\">None</code>.</p></li>\n<li><p><strong>admin.E111</strong>: The value of <code class=\"docutils literal notranslate\">list_display_links[n]</code> refers to <code class=\"docutils literal notranslate\">&lt;label&gt;</code>,\nwhich is not defined in <code class=\"docutils literal notranslate\">list_display</code>.</p></li>\n<li><p><strong>admin.E112</strong>: The value of <code class=\"docutils literal notranslate\">list_filter</code> must be a list or tuple.</p></li>\n<li><p><strong>admin.E113</strong>: The value of <code class=\"docutils literal notranslate\">list_filter[n]</code> must inherit from\n<code class=\"docutils literal notranslate\">ListFilter</code>.</p></li>\n<li><p><strong>admin.E114</strong>: The value of <code class=\"docutils literal notranslate\">list_filter[n]</code> must not inherit from\n<code class=\"docutils literal notranslate\">FieldListFilter</code>.</p></li>\n<li><p><strong>admin.E115</strong>: The value of <code class=\"docutils literal notranslate\">list_filter[n][1]</code> must inherit from\n<code class=\"docutils literal notranslate\">FieldListFilter</code>.</p></li>\n<li><p><strong>admin.E116</strong>: The value of <code class=\"docutils literal notranslate\">list_filter[n]</code> refers to <code class=\"docutils literal notranslate\">&lt;label&gt;</code>,\nwhich does not refer to a Field.</p></li>\n<li><p><strong>admin.E117</strong>: The value of <code class=\"docutils literal notranslate\">list_select_related</code> must be a boolean,\ntuple or list.</p></li>\n<li><p><strong>admin.E118</strong>: The value of <code class=\"docutils literal notranslate\">list_per_page</code> must be an integer.</p></li>\n<li><p><strong>admin.E119</strong>: The value of <code class=\"docutils literal notranslate\">list_max_show_all</code> must be an integer.</p></li>\n<li><p><strong>admin.E120</strong>: The value of <code class=\"docutils literal notranslate\">list_editable</code> must be a list or tuple.</p></li>\n<li><p><strong>admin.E121</strong>: The value of <code class=\"docutils literal notranslate\">list_editable[n]</code> refers to <code class=\"docutils literal notranslate\">&lt;label&gt;</code>,\nwhich is not an attribute of <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E122</strong>: The value of <code class=\"docutils literal notranslate\">list_editable[n]</code> refers to <code class=\"docutils literal notranslate\">&lt;label&gt;</code>,\nwhich is not contained in <code class=\"docutils literal notranslate\">list_display</code>.</p></li>\n<li><p><strong>admin.E123</strong>: The value of <code class=\"docutils literal notranslate\">list_editable[n]</code> cannot be in both\n<code class=\"docutils literal notranslate\">list_editable</code> and <code class=\"docutils literal notranslate\">list_display_links</code>.</p></li>\n<li><p><strong>admin.E124</strong>: The value of <code class=\"docutils literal notranslate\">list_editable[n]</code> refers to the first field\nin <code class=\"docutils literal notranslate\">list_display</code> (<code class=\"docutils literal notranslate\">&lt;label&gt;</code>), which cannot be used unless\n<code class=\"docutils literal notranslate\">list_display_links</code> is set.</p></li>\n<li><p><strong>admin.E125</strong>: The value of <code class=\"docutils literal notranslate\">list_editable[n]</code> refers to <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>,\nwhich is not editable through the admin.</p></li>\n<li><p><strong>admin.E126</strong>: The value of <code class=\"docutils literal notranslate\">search_fields</code> must be a list or tuple.</p></li>\n<li><p><strong>admin.E127</strong>: The value of <code class=\"docutils literal notranslate\">date_hierarchy</code> refers to <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>,\nwhich does not refer to a Field.</p></li>\n<li><p><strong>admin.E128</strong>: The value of <code class=\"docutils literal notranslate\">date_hierarchy</code> must be a <code class=\"docutils literal notranslate\">DateField</code> or\n<code class=\"docutils literal notranslate\">DateTimeField</code>.</p></li>\n<li><p><strong>admin.E129</strong>: <code class=\"docutils literal notranslate\">&lt;modeladmin&gt;</code> must define a <code class=\"docutils literal notranslate\">has_&lt;foo&gt;_permission()</code>\nmethod for the <code class=\"docutils literal notranslate\">&lt;action&gt;</code> action.</p></li>\n<li><p><strong>admin.E130</strong>: <code class=\"docutils literal notranslate\">__name__</code> attributes of actions defined in\n<code class=\"docutils literal notranslate\">&lt;modeladmin&gt;</code> must be unique.</p></li>\n</ul>\n</section>\n<section id=\"inlinemodeladmin\">\n<h4><code class=\"docutils literal notranslate\">InlineModelAdmin</code><a class=\"heading-anchor\" href=\"#inlinemodeladmin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>The following checks are performed on any\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin\" title=\"django.contrib.admin.InlineModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">InlineModelAdmin</code></a> that is registered as an\ninline on a <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin\" title=\"django.contrib.admin.ModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">ModelAdmin</code></a>.</p>\n<ul class=\"simple\">\n<li><p><strong>admin.E201</strong>: Cannot exclude the field <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>, because it is the\nforeign key to the parent model <code class=\"docutils literal notranslate\">&lt;app_label&gt;.&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E202</strong>: <code class=\"docutils literal notranslate\">&lt;model&gt;</code> has no <code class=\"docutils literal notranslate\">ForeignKey</code> to <code class=\"docutils literal notranslate\">&lt;parent model&gt;</code>./\n<code class=\"docutils literal notranslate\">&lt;model&gt;</code> has more than one <code class=\"docutils literal notranslate\">ForeignKey</code> to <code class=\"docutils literal notranslate\">&lt;parent model&gt;</code>.</p></li>\n<li><p><strong>admin.E203</strong>: The value of <code class=\"docutils literal notranslate\">extra</code> must be an integer.</p></li>\n<li><p><strong>admin.E204</strong>: The value of <code class=\"docutils literal notranslate\">max_num</code> must be an integer.</p></li>\n<li><p><strong>admin.E205</strong>: The value of <code class=\"docutils literal notranslate\">min_num</code> must be an integer.</p></li>\n<li><p><strong>admin.E206</strong>: The value of <code class=\"docutils literal notranslate\">formset</code> must inherit from\n<code class=\"docutils literal notranslate\">BaseModelFormSet</code>.</p></li>\n</ul>\n</section>\n<section id=\"genericinlinemodeladmin\">\n<h4><code class=\"docutils literal notranslate\">GenericInlineModelAdmin</code><a class=\"heading-anchor\" href=\"#genericinlinemodeladmin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>The following checks are performed on any\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/contenttypes/#django.contrib.contenttypes.admin.GenericInlineModelAdmin\" title=\"django.contrib.contenttypes.admin.GenericInlineModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">GenericInlineModelAdmin</code></a> that is\nregistered as an inline on a <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin\" title=\"django.contrib.admin.ModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">ModelAdmin</code></a>.</p>\n<ul class=\"simple\">\n<li><p><strong>admin.E301</strong>: <code class=\"docutils literal notranslate\">'ct_field'</code> references <code class=\"docutils literal notranslate\">&lt;label&gt;</code>, which is not a field\non <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E302</strong>: <code class=\"docutils literal notranslate\">'ct_fk_field'</code> references <code class=\"docutils literal notranslate\">&lt;label&gt;</code>, which is not a\nfield on <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>admin.E303</strong>: <code class=\"docutils literal notranslate\">&lt;model&gt;</code> has no <code class=\"docutils literal notranslate\">GenericForeignKey</code>.</p></li>\n<li><p><strong>admin.E304</strong>: <code class=\"docutils literal notranslate\">&lt;model&gt;</code> has no <code class=\"docutils literal notranslate\">GenericForeignKey</code> using content type\nfield <code class=\"docutils literal notranslate\">&lt;field name&gt;</code> and object ID field <code class=\"docutils literal notranslate\">&lt;field name&gt;</code>.</p></li>\n</ul>\n</section>\n<section id=\"adminsite\">\n<h4><code class=\"docutils literal notranslate\">AdminSite</code><a class=\"heading-anchor\" href=\"#adminsite\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>The following checks are performed on the default\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/admin/#django.contrib.admin.AdminSite\" title=\"django.contrib.admin.AdminSite\"><code class=\"xref py py-class docutils literal notranslate\">AdminSite</code></a>:</p>\n<ul class=\"simple\">\n<li><p><strong>admin.E401</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/contenttypes/#module-django.contrib.contenttypes\" title=\"django.contrib.contenttypes: Provides generic interface to installed models.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.contenttypes</code></a> must be in\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> in order to use the admin application.</p></li>\n<li><p><strong>admin.E402</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/templates/api/#django.contrib.auth.context_processors.auth\" title=\"django.contrib.auth.context_processors.auth\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.auth.context_processors.auth</code></a>\nmust be enabled in <a class=\"reference internal\" href=\"/zh-hans/3.0/topics/templates/#django.template.backends.django.DjangoTemplates\" title=\"django.template.backends.django.DjangoTemplates\"><code class=\"xref py py-class docutils literal notranslate\">DjangoTemplates</code></a>\n(<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-TEMPLATES\"><code class=\"xref std std-setting docutils literal notranslate\">TEMPLATES</code></a>) if using the default auth backend in order to use the\nadmin application.</p></li>\n<li><p><strong>admin.E403</strong>: A <a class=\"reference internal\" href=\"/zh-hans/3.0/topics/templates/#django.template.backends.django.DjangoTemplates\" title=\"django.template.backends.django.DjangoTemplates\"><code class=\"xref py py-class docutils literal notranslate\">django.template.backends.django.DjangoTemplates</code></a>\ninstance must be configured in <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-TEMPLATES\"><code class=\"xref std std-setting docutils literal notranslate\">TEMPLATES</code></a> in order to use the\nadmin application.</p></li>\n<li><p><strong>admin.E404</strong>: <code class=\"docutils literal notranslate\">django.contrib.messages.context_processors.messages</code>\nmust be enabled in <a class=\"reference internal\" href=\"/zh-hans/3.0/topics/templates/#django.template.backends.django.DjangoTemplates\" title=\"django.template.backends.django.DjangoTemplates\"><code class=\"xref py py-class docutils literal notranslate\">DjangoTemplates</code></a>\n(<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-TEMPLATES\"><code class=\"xref std std-setting docutils literal notranslate\">TEMPLATES</code></a>) in order to use the admin application.</p></li>\n<li><p><strong>admin.E405</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/topics/auth/#module-django.contrib.auth\" title=\"django.contrib.auth: Django's authentication framework.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.auth</code></a> must be in\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> in order to use the admin application.</p></li>\n<li><p><strong>admin.E406</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/messages/#module-django.contrib.messages\" title=\"django.contrib.messages: Provides cookie- and session-based temporary message storage.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.messages</code></a> must be in\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> in order to use the admin application.</p></li>\n<li><p><strong>admin.E408</strong>:\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/middleware/#django.contrib.auth.middleware.AuthenticationMiddleware\" title=\"django.contrib.auth.middleware.AuthenticationMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">django.contrib.auth.middleware.AuthenticationMiddleware</code></a> must be in\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</code></a> in order to use the admin application.</p></li>\n<li><p><strong>admin.E409</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/middleware/#django.contrib.messages.middleware.MessageMiddleware\" title=\"django.contrib.messages.middleware.MessageMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">django.contrib.messages.middleware.MessageMiddleware</code></a>\nmust be in <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</code></a> in order to use the admin application.</p></li>\n<li><p><strong>admin.E410</strong>: <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/middleware/#django.contrib.sessions.middleware.SessionMiddleware\" title=\"django.contrib.sessions.middleware.SessionMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">django.contrib.sessions.middleware.SessionMiddleware</code></a>\nmust be in <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</code></a> in order to use the admin application.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"auth\">\n<h3><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></h3>\n<ul class=\"simple\">\n<li><p><strong>auth.E001</strong>: <code class=\"docutils literal notranslate\">REQUIRED_FIELDS</code> must be a list or tuple.</p></li>\n<li><p><strong>auth.E002</strong>: The field named as the <code class=\"docutils literal notranslate\">USERNAME_FIELD</code> for a custom user\nmodel must not be included in <code class=\"docutils literal notranslate\">REQUIRED_FIELDS</code>.</p></li>\n<li><p><strong>auth.E003</strong>: <code class=\"docutils literal notranslate\">&lt;field&gt;</code> must be unique because it is named as the\n<code class=\"docutils literal notranslate\">USERNAME_FIELD</code>.</p></li>\n<li><p><strong>auth.W004</strong>: <code class=\"docutils literal notranslate\">&lt;field&gt;</code> is named as the <code class=\"docutils literal notranslate\">USERNAME_FIELD</code>, but it is not\nunique.</p></li>\n<li><p><strong>auth.E005</strong>: The permission codenamed <code class=\"docutils literal notranslate\">&lt;codename&gt;</code> clashes with a builtin\npermission for model <code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>auth.E006</strong>: The permission codenamed <code class=\"docutils literal notranslate\">&lt;codename&gt;</code> is duplicated for model\n<code class=\"docutils literal notranslate\">&lt;model&gt;</code>.</p></li>\n<li><p><strong>auth.E007</strong>: The <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/models/options/#django.db.models.Options.verbose_name\" title=\"django.db.models.Options.verbose_name\"><code class=\"xref py py-attr docutils literal notranslate\">verbose_name</code></a> of model <code class=\"docutils literal notranslate\">&lt;model&gt;</code> must be at most\n244 characters for its builtin permission names\nto be at most 255 characters.</p></li>\n<li><p><strong>auth.E008</strong>: The permission named <code class=\"docutils literal notranslate\">&lt;name&gt;</code> of model <code class=\"docutils literal notranslate\">&lt;model&gt;</code> is longer\nthan 255 characters.</p></li>\n<li><p><strong>auth.C009</strong>: <code class=\"docutils literal notranslate\">&lt;User model&gt;.is_anonymous</code> must be an attribute or property\nrather than a method. Ignoring this is a security issue as anonymous users\nwill be treated as authenticated!</p></li>\n<li><p><strong>auth.C010</strong>: <code class=\"docutils literal notranslate\">&lt;User model&gt;.is_authenticated</code> must be an attribute or\nproperty rather than a method. Ignoring this is a security issue as anonymous\nusers will be treated as authenticated!</p></li>\n</ul>\n</section>\n<section id=\"contenttypes\">\n<h3><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></h3>\n<p>The following checks are performed when a model contains a\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/contenttypes/#django.contrib.contenttypes.fields.GenericForeignKey\" title=\"django.contrib.contenttypes.fields.GenericForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">GenericForeignKey</code></a> or\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/contenttypes/#django.contrib.contenttypes.fields.GenericRelation\" title=\"django.contrib.contenttypes.fields.GenericRelation\"><code class=\"xref py py-class docutils literal notranslate\">GenericRelation</code></a>:</p>\n<ul class=\"simple\">\n<li><p><strong>contenttypes.E001</strong>: The <code class=\"docutils literal notranslate\">GenericForeignKey</code> object ID references the\nnonexistent field <code class=\"docutils literal notranslate\">&lt;field&gt;</code>.</p></li>\n<li><p><strong>contenttypes.E002</strong>: The <code class=\"docutils literal notranslate\">GenericForeignKey</code> content type references the\nnonexistent field <code class=\"docutils literal notranslate\">&lt;field&gt;</code>.</p></li>\n<li><p><strong>contenttypes.E003</strong>: <code class=\"docutils literal notranslate\">&lt;field&gt;</code> is not a <code class=\"docutils literal notranslate\">ForeignKey</code>.</p></li>\n<li><p><strong>contenttypes.E004</strong>: <code class=\"docutils literal notranslate\">&lt;field&gt;</code> is not a <code class=\"docutils literal notranslate\">ForeignKey</code> to\n<code class=\"docutils literal notranslate\">contenttypes.ContentType</code>.</p></li>\n<li><p><strong>contenttypes.E005</strong>: Model names must be at most 100 characters.</p></li>\n</ul>\n</section>\n<section id=\"postgres\">\n<h3><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></h3>\n<p>The following checks are performed on <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/postgres/#module-django.contrib.postgres\" title=\"django.contrib.postgres: PostgreSQL-specific fields and features\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.postgres</code></a> model\nfields:</p>\n<ul class=\"simple\">\n<li><p><strong>postgres.E001</strong>: Base field for array has errors: ...</p></li>\n<li><p><strong>postgres.E002</strong>: Base field for array cannot be a related field.</p></li>\n<li><p><strong>postgres.E003</strong>: <code class=\"docutils literal notranslate\">&lt;field&gt;</code> default should be a callable instead of an\ninstance so that it's not shared between all field instances.</p></li>\n</ul>\n</section>\n<section id=\"sites\">\n<h3><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></h3>\n<p>The following checks are performed on any model using a\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/sites/#django.contrib.sites.managers.CurrentSiteManager\" title=\"django.contrib.sites.managers.CurrentSiteManager\"><code class=\"xref py py-class docutils literal notranslate\">CurrentSiteManager</code></a>:</p>\n<ul class=\"simple\">\n<li><p><strong>sites.E001</strong>: <code class=\"docutils literal notranslate\">CurrentSiteManager</code> could not find a field named\n<code class=\"docutils literal notranslate\">&lt;field name&gt;</code>.</p></li>\n<li><p><strong>sites.E002</strong>: <code class=\"docutils literal notranslate\">CurrentSiteManager</code> cannot use <code class=\"docutils literal notranslate\">&lt;field&gt;</code> as it is not a\nforeign key or a many-to-many field.</p></li>\n</ul>\n</section>\n<section id=\"staticfiles\">\n<h3><code class=\"docutils literal notranslate\">staticfiles</code><a class=\"heading-anchor\" href=\"#staticfiles\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The following checks verify that <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/contrib/staticfiles/#module-django.contrib.staticfiles\" title=\"django.contrib.staticfiles: An app for handling static files.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.staticfiles</code></a> is correctly\nconfigured:</p>\n<ul class=\"simple\">\n<li><p><strong>staticfiles.E001</strong>: The <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-STATICFILES_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_DIRS</code></a> setting is not a tuple\nor list.</p></li>\n<li><p><strong>staticfiles.E002</strong>: The <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-STATICFILES_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_DIRS</code></a> setting should not\ncontain the <a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_ROOT</code></a> setting.</p></li>\n<li><p><strong>staticfiles.E003</strong>: The prefix <code class=\"docutils literal notranslate\">&lt;prefix&gt;</code> in the\n<a class=\"reference internal\" href=\"/zh-hans/3.0/ref/settings/#std-setting-STATICFILES_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_DIRS</code></a> setting must not end with a slash.</p></li>\n</ul>\n</section>\n</section>","rootId":"system-check-framework","toc":[{"title":"API 参考","anchor":"api-reference","children":[{"title":"“CheckMessage”","anchor":"checkmessage","children":[]}]},{"title":"内置标签","anchor":"builtin-tags","children":[]},{"title":"核心系统检查","anchor":"core-system-checks","children":[{"title":"向后兼容","anchor":"backwards-compatibility","children":[]},{"title":"缓存","anchor":"caches","children":[]},{"title":"数据库","anchor":"database","children":[{"title":"MySQL","anchor":"mysql","children":[]}]},{"title":"模型字段","anchor":"model-fields","children":[{"title":"文件字段","anchor":"file-fields","children":[]},{"title":"关联字段","anchor":"related-fields","children":[]}]},{"title":"模型","anchor":"models","children":[]},{"title":"安全","anchor":"security","children":[]},{"title":"信号","anchor":"signals","children":[]},{"title":"模板","anchor":"templates","children":[]},{"title":"翻译","anchor":"translation","children":[]},{"title":"URLs","anchor":"urls","children":[]}]},{"title":"contrib 应用检查","anchor":"contrib-app-checks","children":[{"title":"admin","anchor":"admin","children":[{"title":"ModelAdmin","anchor":"modeladmin","children":[]},{"title":"InlineModelAdmin","anchor":"inlinemodeladmin","children":[]},{"title":"GenericInlineModelAdmin","anchor":"genericinlinemodeladmin","children":[]},{"title":"AdminSite","anchor":"adminsite","children":[]}]},{"title":"auth","anchor":"auth","children":[]},{"title":"contenttypes","anchor":"contenttypes","children":[]},{"title":"postgres","anchor":"postgres","children":[]},{"title":"sites","anchor":"sites","children":[]},{"title":"staticfiles","anchor":"staticfiles","children":[]}]}],"breadcrumbs":[{"docname":"ref/index","title":"API参考","url":"/zh-hans/3.0/ref/"}],"prev":{"docname":"ref/applications","title":"应用","url":"/zh-hans/3.0/ref/applications/"},"next":{"docname":"ref/class-based-views/index","title":"Built-in class-based views API","url":"/zh-hans/3.0/ref/class-based-views/"},"formats":{"html":"/zh-hans/3.0/ref/checks/","markdown":"/zh-hans/3.0/ref/checks.md","json":"/zh-hans/3.0/ref/checks.json"},"source":"https://github.com/django/django/blob/stable/3.0.x/docs/ref/checks.txt","official":"https://docs.djangoproject.com/zh-hans/3.0/ref/checks/","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"]}