{"title":"django-admin and manage.py","version":"2.2","locale":"zh-hans","docname":"ref/django-admin","url":"/zh-hans/2.2/ref/django-admin/","canonical":"https://djangodocs.dev/zh-hans/2.2/ref/django-admin/","summary":"django-admin is Django's command-line utility for administrative tasks. This document outlines all it can do. In addition, manage.py is automatically created in…","html":"<section id=\"django-admin-and-manage-py\">\n<h1><code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code><a class=\"heading-anchor\" href=\"#django-admin-and-manage-py\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> is Django's command-line utility for administrative tasks.\nThis document outlines all it can do.</p>\n<p>In addition, <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code> is automatically created in each Django project. It\ndoes the same thing as <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> but also sets the\n<span class=\"target\" id=\"index-0\"></span><a class=\"reference internal\" href=\"/zh-hans/2.2/topics/settings/#envvar-DJANGO_SETTINGS_MODULE\"><code class=\"xref std std-envvar docutils literal notranslate\"><span class=\"pre\">DJANGO_SETTINGS_MODULE</span></code></a> environment variable so that it points to your\nproject's <code class=\"docutils literal notranslate\"><span class=\"pre\">settings.py</span></code> file.</p>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> script should be on your system path if you installed\nDjango via <code class=\"docutils literal notranslate\"><span class=\"pre\">pip</span></code>. If it's not on your path, you can find it in\n<code class=\"docutils literal notranslate\"><span class=\"pre\">site-packages/django/bin</span></code> within your Python installation. Consider\nsymlinking it from some place on your path, such as <code class=\"docutils literal notranslate\"><span class=\"pre\">/usr/local/bin</span></code>.</p>\n<p>For Windows users, who do not have symlinking functionality available, you can\ncopy <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin.exe</span></code> to a location on your existing path or edit the\n<code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> settings (under <code class=\"docutils literal notranslate\"><span class=\"pre\">Settings</span> <span class=\"pre\">-</span> <span class=\"pre\">Control</span> <span class=\"pre\">Panel</span> <span class=\"pre\">-</span> <span class=\"pre\">System</span> <span class=\"pre\">-</span> <span class=\"pre\">Advanced</span> <span class=\"pre\">-</span>\n<span class=\"pre\">Environment...</span></code>) to point to its installed location.</p>\n<p>Generally, when working on a single Django project, it's easier to use\n<code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code> than <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code>. If you need to switch between multiple\nDjango settings files, use <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> with\n<span class=\"target\" id=\"index-1\"></span><a class=\"reference internal\" href=\"/zh-hans/2.2/topics/settings/#envvar-DJANGO_SETTINGS_MODULE\"><code class=\"xref std std-envvar docutils literal notranslate\"><span class=\"pre\">DJANGO_SETTINGS_MODULE</span></code></a> or the <a class=\"reference internal\" href=\"#cmdoption-settings\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--settings</span></code></a> command line\noption.</p>\n<p>The command-line examples throughout this document use <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> to\nbe consistent, but any example can use <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">python</span> <span class=\"pre\">-m</span> <span class=\"pre\">django</span></code>\njust as well.</p>\n<section id=\"usage\">\n<h2>用法<a class=\"heading-anchor\" href=\"#usage\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-0-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>django-admin<span class=\"w\"> </span>&lt;command&gt;<span class=\"w\"> </span><span class=\"o\">[</span>options<span class=\"o\">]</span>\n<span class=\"gp\">$ </span>manage.py<span class=\"w\"> </span>&lt;command&gt;<span class=\"w\"> </span><span class=\"o\">[</span>options<span class=\"o\">]</span>\n<span class=\"gp\">$ </span>python<span class=\"w\"> </span>-m<span class=\"w\"> </span>django<span class=\"w\"> </span>&lt;command&gt;<span class=\"w\"> </span><span class=\"o\">[</span>options<span class=\"o\">]</span>\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-0-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> django-admin <span class=\"p\">&lt;</span>command<span class=\"p\">&gt;</span> [options]\n<span class=\"gp\">...\\&gt;</span> manage.py <span class=\"p\">&lt;</span>command<span class=\"p\">&gt;</span> [options]\n<span class=\"gp\">...\\&gt;</span> py -m django <span class=\"p\">&lt;</span>command<span class=\"p\">&gt;</span> [options]\n</code></pre></div></div></div>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">command</span></code> should be one of the commands listed in this document.\n<code class=\"docutils literal notranslate\"><span class=\"pre\">options</span></code>, which is optional, should be zero or more of the options available\nfor the given command.</p>\n<section id=\"getting-runtime-help\">\n<h3>Getting runtime help<a class=\"heading-anchor\" href=\"#getting-runtime-help\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-help\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">help</span></span><a class=\"heading-anchor\" href=\"#django-admin-help\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Run <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span> <span class=\"pre\">help</span></code> to display usage information and a list of the\ncommands provided by each application.</p>\n<p>Run <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span> <span class=\"pre\">help</span> <span class=\"pre\">--commands</span></code> to display a list of all available\ncommands.</p>\n<p>Run <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span> <span class=\"pre\">help</span> <span class=\"pre\">&lt;command&gt;</span></code> to display a description of the given\ncommand and a list of its available options.</p>\n</section>\n<section id=\"app-names\">\n<h3>App names<a class=\"heading-anchor\" href=\"#app-names\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Many commands take a list of &quot;app names.&quot; An &quot;app name&quot; is the basename of\nthe package containing your models. For example, if your <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a>\ncontains the string <code class=\"docutils literal notranslate\"><span class=\"pre\">'mysite.blog'</span></code>, the app name is <code class=\"docutils literal notranslate\"><span class=\"pre\">blog</span></code>.</p>\n</section>\n<section id=\"determining-the-version\">\n<h3>Determining the version<a class=\"heading-anchor\" href=\"#determining-the-version\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-version\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">version</span></span><a class=\"heading-anchor\" href=\"#django-admin-version\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Run <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span> <span class=\"pre\">version</span></code> to display the current Django version.</p>\n<p>The output follows the schema described in <span class=\"target\" id=\"index-2\"></span><a class=\"pep reference external\" href=\"https://peps.python.org/pep-0440/\"><strong>PEP 440</strong></a>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"mf\">1.4</span><span class=\"o\">.</span><span class=\"n\">dev17026</span>\n<span class=\"mf\">1.4</span><span class=\"n\">a1</span>\n<span class=\"mf\">1.4</span>\n</code></pre></div>\n</section>\n<section id=\"displaying-debug-output\">\n<h3>Displaying debug output<a class=\"heading-anchor\" href=\"#displaying-debug-output\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Use <a class=\"reference internal\" href=\"#cmdoption-verbosity\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--verbosity</span></code></a> to specify the amount of notification and debug\ninformation that <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> prints to the console.</p>\n</section>\n</section>\n<section id=\"available-commands\">\n<h2>Available commands<a class=\"heading-anchor\" href=\"#available-commands\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"check\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">check</span></code><a class=\"heading-anchor\" href=\"#check\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-check\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">check</span> <span class=\"pre\">[app_label</span> <span class=\"pre\">[app_label</span> <span class=\"pre\">...]]</span></span><a class=\"heading-anchor\" href=\"#django-admin-check\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Uses the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/checks/\"><span class=\"doc\">system check framework</span></a> to inspect the entire\nDjango project for common problems.</p>\n<p>By default, all apps will be checked. You can check a subset of apps by\nproviding a list of app labels as arguments:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">check</span> <span class=\"n\">auth</span> <span class=\"n\">admin</span> <span class=\"n\">myapp</span>\n</code></pre></div>\n<p>If you do not specify any app, all apps will be checked.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-check-tag\">\n<span id=\"cmdoption-check-t\"></span><span class=\"sig-name descname\"><span class=\"pre\">--tag</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">TAGS</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-t</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">TAGS</span></span><a class=\"heading-anchor\" href=\"#cmdoption-check-tag\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The system check framework performs many different types of checks that are\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/checks/#system-check-builtin-tags\"><span class=\"std std-ref\">categorized with tags</span></a>. You can use these\ntags to restrict the checks performed to just those in a particular category.\nFor example, to perform only models and compatibility checks, run:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">check</span> <span class=\"o\">--</span><span class=\"n\">tag</span> <span class=\"n\">models</span> <span class=\"o\">--</span><span class=\"n\">tag</span> <span class=\"n\">compatibility</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-check-list-tags\">\n<span class=\"sig-name descname\"><span class=\"pre\">--list-tags</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-check-list-tags\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Lists all available tags.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-check-deploy\">\n<span class=\"sig-name descname\"><span class=\"pre\">--deploy</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-check-deploy\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Activates some additional checks that are only relevant in a deployment setting.</p>\n<p>You can use this option in your local development environment, but since your\nlocal development settings module may not have many of your production settings,\nyou will probably want to point the <code class=\"docutils literal notranslate\"><span class=\"pre\">check</span></code> command at a different settings\nmodule, either by setting the <code class=\"docutils literal notranslate\"><span class=\"pre\">DJANGO_SETTINGS_MODULE</span></code> environment variable,\nor by passing the <code class=\"docutils literal notranslate\"><span class=\"pre\">--settings</span></code> option:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">check</span> <span class=\"o\">--</span><span class=\"n\">deploy</span> <span class=\"o\">--</span><span class=\"n\">settings</span><span class=\"o\">=</span><span class=\"n\">production_settings</span>\n</code></pre></div>\n<p>Or you could run it directly on a production or staging deployment to verify\nthat the correct settings are in use (omitting <code class=\"docutils literal notranslate\"><span class=\"pre\">--settings</span></code>). You could even\nmake it part of your integration test suite.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-check-fail-level\">\n<span class=\"sig-name descname\"><span class=\"pre\">--fail-level</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">{CRITICAL,ERROR,WARNING,INFO,DEBUG}</span></span><a class=\"heading-anchor\" href=\"#cmdoption-check-fail-level\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the message level that will cause the command to exit with a non-zero\nstatus. Default is <code class=\"docutils literal notranslate\"><span class=\"pre\">ERROR</span></code>.</p>\n</section>\n<section id=\"compilemessages\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">compilemessages</span></code><a class=\"heading-anchor\" href=\"#compilemessages\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-compilemessages\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">compilemessages</span></span><a class=\"heading-anchor\" href=\"#django-admin-compilemessages\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Compiles <code class=\"docutils literal notranslate\"><span class=\"pre\">.po</span></code> files created by <a class=\"reference internal\" href=\"#django-admin-makemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">makemessages</span></code></a> to <code class=\"docutils literal notranslate\"><span class=\"pre\">.mo</span></code> files for\nuse with the built-in gettext support. See <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/i18n/\"><span class=\"doc\">国际化和本地化</span></a>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-compilemessages-locale\">\n<span id=\"cmdoption-compilemessages-l\"></span><span class=\"sig-name descname\"><span class=\"pre\">--locale</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">LOCALE</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-l</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">LOCALE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-compilemessages-locale\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the locale(s) to process. If not provided, all locales are processed.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-compilemessages-exclude\">\n<span id=\"cmdoption-compilemessages-x\"></span><span class=\"sig-name descname\"><span class=\"pre\">--exclude</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXCLUDE</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-x</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXCLUDE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-compilemessages-exclude\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the locale(s) to exclude from processing. If not provided, no locales\nare excluded.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-compilemessages-use-fuzzy\">\n<span id=\"cmdoption-compilemessages-f\"></span><span class=\"sig-name descname\"><span class=\"pre\">--use-fuzzy</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-f</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-compilemessages-use-fuzzy\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Includes fuzzy translations into compiled files.</p>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">compilemessages</span> <span class=\"o\">--</span><span class=\"n\">locale</span><span class=\"o\">=</span><span class=\"n\">pt_BR</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">compilemessages</span> <span class=\"o\">--</span><span class=\"n\">locale</span><span class=\"o\">=</span><span class=\"n\">pt_BR</span> <span class=\"o\">--</span><span class=\"n\">locale</span><span class=\"o\">=</span><span class=\"n\">fr</span> <span class=\"o\">-</span><span class=\"n\">f</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">compilemessages</span> <span class=\"o\">-</span><span class=\"n\">l</span> <span class=\"n\">pt_BR</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">compilemessages</span> <span class=\"o\">-</span><span class=\"n\">l</span> <span class=\"n\">pt_BR</span> <span class=\"o\">-</span><span class=\"n\">l</span> <span class=\"n\">fr</span> <span class=\"o\">--</span><span class=\"n\">use</span><span class=\"o\">-</span><span class=\"n\">fuzzy</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">compilemessages</span> <span class=\"o\">--</span><span class=\"n\">exclude</span><span class=\"o\">=</span><span class=\"n\">pt_BR</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">compilemessages</span> <span class=\"o\">--</span><span class=\"n\">exclude</span><span class=\"o\">=</span><span class=\"n\">pt_BR</span> <span class=\"o\">--</span><span class=\"n\">exclude</span><span class=\"o\">=</span><span class=\"n\">fr</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">compilemessages</span> <span class=\"o\">-</span><span class=\"n\">x</span> <span class=\"n\">pt_BR</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">compilemessages</span> <span class=\"o\">-</span><span class=\"n\">x</span> <span class=\"n\">pt_BR</span> <span class=\"o\">-</span><span class=\"n\">x</span> <span class=\"n\">fr</span>\n</code></pre></div>\n</section>\n<section id=\"createcachetable\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">createcachetable</span></code><a class=\"heading-anchor\" href=\"#createcachetable\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-createcachetable\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">createcachetable</span></span><a class=\"heading-anchor\" href=\"#django-admin-createcachetable\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Creates the cache tables for use with the database cache backend using the\ninformation from your settings file. See <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/cache/\"><span class=\"doc\">Django 缓存框架</span></a> for more\ninformation.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-createcachetable-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-createcachetable-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database in which the cache table(s) will be created. Defaults to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-createcachetable-dry-run\">\n<span class=\"sig-name descname\"><span class=\"pre\">--dry-run</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-createcachetable-dry-run\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Prints the SQL that would be run without actually running it, so you can\ncustomize it or use the migrations framework.</p>\n</section>\n<section id=\"dbshell\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">dbshell</span></code><a class=\"heading-anchor\" href=\"#dbshell\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-dbshell\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">dbshell</span></span><a class=\"heading-anchor\" href=\"#django-admin-dbshell\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Runs the command-line client for the database engine specified in your\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-DATABASE-ENGINE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ENGINE</span></code></a> setting, with the connection parameters\nspecified in your <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-USER\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">USER</span></code></a>, <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-PASSWORD\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">PASSWORD</span></code></a>, etc., settings.</p>\n<ul class=\"simple\">\n<li><p>For PostgreSQL, this runs the <code class=\"docutils literal notranslate\"><span class=\"pre\">psql</span></code> command-line client.</p></li>\n<li><p>For MySQL, this runs the <code class=\"docutils literal notranslate\"><span class=\"pre\">mysql</span></code> command-line client.</p></li>\n<li><p>For SQLite, this runs the <code class=\"docutils literal notranslate\"><span class=\"pre\">sqlite3</span></code> command-line client.</p></li>\n<li><p>For Oracle, this runs the <code class=\"docutils literal notranslate\"><span class=\"pre\">sqlplus</span></code> command-line client.</p></li>\n</ul>\n<p>This command assumes the programs are on your <code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> so that a simple call to\nthe program name (<code class=\"docutils literal notranslate\"><span class=\"pre\">psql</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">mysql</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">sqlite3</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">sqlplus</span></code>) will find the\nprogram in the right place. There's no way to specify the location of the\nprogram manually.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-dbshell-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-dbshell-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database onto which to open a shell. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>Be aware that not all options set it in the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-OPTIONS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">OPTIONS</span></code></a> part of your\ndatabase configuration in <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-DATABASES\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DATABASES</span></code></a> are passed to the\ncommand-line client, e.g. <code class=\"docutils literal notranslate\"><span class=\"pre\">'isolation_level'</span></code>.</p>\n</aside>\n</section>\n<section id=\"diffsettings\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">diffsettings</span></code><a class=\"heading-anchor\" href=\"#diffsettings\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-diffsettings\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">diffsettings</span></span><a class=\"heading-anchor\" href=\"#django-admin-diffsettings\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Displays differences between the current settings file and Django's default\nsettings (or another settings file specified by <a class=\"reference internal\" href=\"#cmdoption-diffsettings-default\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--default</span></code></a>).</p>\n<p>Settings that don't appear in the defaults are followed by <code class=\"docutils literal notranslate\"><span class=\"pre\">&quot;###&quot;</span></code>. For\nexample, the default settings don't define <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-ROOT_URLCONF\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ROOT_URLCONF</span></code></a>, so\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-ROOT_URLCONF\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ROOT_URLCONF</span></code></a> is followed by <code class=\"docutils literal notranslate\"><span class=\"pre\">&quot;###&quot;</span></code> in the output of\n<code class=\"docutils literal notranslate\"><span class=\"pre\">diffsettings</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-diffsettings-all\">\n<span class=\"sig-name descname\"><span class=\"pre\">--all</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-diffsettings-all\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Displays all settings, even if they have Django's default value. Such settings\nare prefixed by <code class=\"docutils literal notranslate\"><span class=\"pre\">&quot;###&quot;</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-diffsettings-default\">\n<span class=\"sig-name descname\"><span class=\"pre\">--default</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">MODULE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-diffsettings-default\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The settings module to compare the current settings against. Leave empty to\ncompare against Django's default settings.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-diffsettings-output\">\n<span class=\"sig-name descname\"><span class=\"pre\">--output</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">{hash,unified}</span></span><a class=\"heading-anchor\" href=\"#cmdoption-diffsettings-output\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the output format. Available values are <code class=\"docutils literal notranslate\"><span class=\"pre\">hash</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">unified</span></code>.\n<code class=\"docutils literal notranslate\"><span class=\"pre\">hash</span></code> is the default mode that displays the output that's described above.\n<code class=\"docutils literal notranslate\"><span class=\"pre\">unified</span></code> displays the output similar to <code class=\"docutils literal notranslate\"><span class=\"pre\">diff</span> <span class=\"pre\">-u</span></code>. Default settings are\nprefixed with a minus sign, followed by the changed setting prefixed with a\nplus sign.</p>\n</section>\n<section id=\"dumpdata\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">dumpdata</span></code><a class=\"heading-anchor\" href=\"#dumpdata\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-dumpdata\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">dumpdata</span> <span class=\"pre\">[app_label[.ModelName]</span> <span class=\"pre\">[app_label[.ModelName]</span> <span class=\"pre\">...]]</span></span><a class=\"heading-anchor\" href=\"#django-admin-dumpdata\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Outputs to standard output all data in the database associated with the named\napplication(s).</p>\n<p>If no application name is provided, all installed applications will be dumped.</p>\n<p>The output of <code class=\"docutils literal notranslate\"><span class=\"pre\">dumpdata</span></code> can be used as input for <a class=\"reference internal\" href=\"#django-admin-loaddata\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">loaddata</span></code></a>.</p>\n<p>Note that <code class=\"docutils literal notranslate\"><span class=\"pre\">dumpdata</span></code> uses the default manager on the model for selecting the\nrecords to dump. If you're using a <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/db/managers/#custom-managers\"><span class=\"std std-ref\">custom manager</span></a> as\nthe default manager and it filters some of the available records, not all of the\nobjects will be dumped.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-dumpdata-all\">\n<span id=\"cmdoption-dumpdata-a\"></span><span class=\"sig-name descname\"><span class=\"pre\">--all</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-a</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-dumpdata-all\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Uses Django's base manager, dumping records which might otherwise be filtered\nor modified by a custom manager.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-dumpdata-format\">\n<span class=\"sig-name descname\"><span class=\"pre\">--format</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">FORMAT</span></span><a class=\"heading-anchor\" href=\"#cmdoption-dumpdata-format\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the serialization format of the output. Defaults to JSON. Supported\nformats are listed in <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/serialization/#serialization-formats\"><span class=\"std std-ref\">Serialization formats</span></a>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-dumpdata-indent\">\n<span class=\"sig-name descname\"><span class=\"pre\">--indent</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">INDENT</span></span><a class=\"heading-anchor\" href=\"#cmdoption-dumpdata-indent\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the number of indentation spaces to use in the output. Defaults to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">None</span></code> which displays all data on single line.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-dumpdata-exclude\">\n<span id=\"cmdoption-dumpdata-e\"></span><span class=\"sig-name descname\"><span class=\"pre\">--exclude</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXCLUDE</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-e</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXCLUDE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-dumpdata-exclude\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Prevents specific applications or models (specified in the form of\n<code class=\"docutils literal notranslate\"><span class=\"pre\">app_label.ModelName</span></code>) from being dumped. If you specify a model name, the\noutput will be restricted to that model, rather than the entire application.\nYou can also mix application names and model names.</p>\n<p>If you want to exclude multiple applications, pass <code class=\"docutils literal notranslate\"><span class=\"pre\">--exclude</span></code> more than\nonce:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">dumpdata</span> <span class=\"o\">--</span><span class=\"n\">exclude</span><span class=\"o\">=</span><span class=\"n\">auth</span> <span class=\"o\">--</span><span class=\"n\">exclude</span><span class=\"o\">=</span><span class=\"n\">contenttypes</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-dumpdata-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-dumpdata-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database from which data will be dumped. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-dumpdata-natural-foreign\">\n<span class=\"sig-name descname\"><span class=\"pre\">--natural-foreign</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-dumpdata-natural-foreign\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Uses the <code class=\"docutils literal notranslate\"><span class=\"pre\">natural_key()</span></code> model method to serialize any foreign key and\nmany-to-many relationship to objects of the type that defines the method. If\nyou're dumping <code class=\"docutils literal notranslate\"><span class=\"pre\">contrib.auth</span></code> <code class=\"docutils literal notranslate\"><span class=\"pre\">Permission</span></code> objects or\n<code class=\"docutils literal notranslate\"><span class=\"pre\">contrib.contenttypes</span></code> <code class=\"docutils literal notranslate\"><span class=\"pre\">ContentType</span></code> objects, you should probably use this\nflag. See the <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/serialization/#topics-serialization-natural-keys\"><span class=\"std std-ref\">natural keys</span></a>\ndocumentation for more details on this and the next option.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-dumpdata-natural-primary\">\n<span class=\"sig-name descname\"><span class=\"pre\">--natural-primary</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-dumpdata-natural-primary\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Omits the primary key in the serialized data of this object since it can be\ncalculated during deserialization.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-dumpdata-pks\">\n<span class=\"sig-name descname\"><span class=\"pre\">--pks</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">PRIMARY_KEYS</span></span><a class=\"heading-anchor\" href=\"#cmdoption-dumpdata-pks\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Outputs only the objects specified by a comma separated list of primary keys.\nThis is only available when dumping one model. By default, all the records of\nthe model are output.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-dumpdata-output\">\n<span id=\"cmdoption-dumpdata-o\"></span><span class=\"sig-name descname\"><span class=\"pre\">--output</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">OUTPUT</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-o</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">OUTPUT</span></span><a class=\"heading-anchor\" href=\"#cmdoption-dumpdata-output\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies a file to write the serialized data to. By default, the data goes to\nstandard output.</p>\n<p>When this option is set and <code class=\"docutils literal notranslate\"><span class=\"pre\">--verbosity</span></code> is greater than 0 (the default), a\nprogress bar is shown in the terminal.</p>\n</section>\n<section id=\"flush\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">flush</span></code><a class=\"heading-anchor\" href=\"#flush\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-flush\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">flush</span></span><a class=\"heading-anchor\" href=\"#django-admin-flush\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Removes all data from the database and re-executes any post-synchronization\nhandlers. The table of which migrations have been applied is not cleared.</p>\n<p>If you would rather start from an empty database and re-run all migrations, you\nshould drop and recreate the database and then run <a class=\"reference internal\" href=\"#django-admin-migrate\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">migrate</span></code></a> instead.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-flush-noinput\">\n<span id=\"cmdoption-flush-no-input\"></span><span class=\"sig-name descname\"><span class=\"pre\">--noinput</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">--no-input</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-flush-noinput\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Suppresses all user prompts.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-flush-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-flush-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database to flush. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n</section>\n<section id=\"inspectdb\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">inspectdb</span></code><a class=\"heading-anchor\" href=\"#inspectdb\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-inspectdb\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">inspectdb</span> <span class=\"pre\">[table</span> <span class=\"pre\">[table</span> <span class=\"pre\">...]]</span></span><a class=\"heading-anchor\" href=\"#django-admin-inspectdb\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Introspects the database tables in the database pointed-to by the\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-NAME\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">NAME</span></code></a> setting and outputs a Django model module (a <code class=\"docutils literal notranslate\"><span class=\"pre\">models.py</span></code>\nfile) to standard output.</p>\n<p>You may choose what tables or views to inspect by passing their names as\narguments. If no arguments are provided, models are created for views only if\nthe <a class=\"reference internal\" href=\"#cmdoption-inspectdb-include-views\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--include-views</span></code></a> option is used. Models for partition tables are\ncreated on PostgreSQL if the <a class=\"reference internal\" href=\"#cmdoption-inspectdb-include-partitions\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--include-partitions</span></code></a> option is used.</p>\n<p>Use this if you have a legacy database with which you'd like to use Django.\nThe script will inspect the database and create a model for each table within\nit.</p>\n<p>As you might expect, the created models will have an attribute for every field\nin the table. Note that <code class=\"docutils literal notranslate\"><span class=\"pre\">inspectdb</span></code> has a few special cases in its field-name\noutput:</p>\n<ul class=\"simple\">\n<li><p>If <code class=\"docutils literal notranslate\"><span class=\"pre\">inspectdb</span></code> cannot map a column's type to a model field type, it'll\nuse <code class=\"docutils literal notranslate\"><span class=\"pre\">TextField</span></code> and will insert the Python comment\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'This</span> <span class=\"pre\">field</span> <span class=\"pre\">type</span> <span class=\"pre\">is</span> <span class=\"pre\">a</span> <span class=\"pre\">guess.'</span></code> next to the field in the generated\nmodel. The recognized fields may depend on apps listed in\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a>. For example, <a class=\"reference internal\" href=\"/zh-hans/2.2/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\"><span class=\"pre\">django.contrib.postgres</span></code></a> adds\nrecognition for several PostgreSQL-specific field types.</p></li>\n<li><p>If the database column name is a Python reserved word (such as\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'pass'</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">'class'</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">'for'</span></code>), <code class=\"docutils literal notranslate\"><span class=\"pre\">inspectdb</span></code> will append\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'_field'</span></code> to the attribute name. For example, if a table has a column\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'for'</span></code>, the generated model will have a field <code class=\"docutils literal notranslate\"><span class=\"pre\">'for_field'</span></code>, with\nthe <code class=\"docutils literal notranslate\"><span class=\"pre\">db_column</span></code> attribute set to <code class=\"docutils literal notranslate\"><span class=\"pre\">'for'</span></code>. <code class=\"docutils literal notranslate\"><span class=\"pre\">inspectdb</span></code> will insert\nthe Python comment\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'Field</span> <span class=\"pre\">renamed</span> <span class=\"pre\">because</span> <span class=\"pre\">it</span> <span class=\"pre\">was</span> <span class=\"pre\">a</span> <span class=\"pre\">Python</span> <span class=\"pre\">reserved</span> <span class=\"pre\">word.'</span></code> next to the\nfield.</p></li>\n</ul>\n<p>This feature is meant as a shortcut, not as definitive model generation. After\nyou run it, you'll want to look over the generated models yourself to make\ncustomizations. In particular, you'll need to rearrange models' order, so that\nmodels that refer to other models are ordered properly.</p>\n<p>Django doesn't create database defaults when a\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/models/fields/#django.db.models.Field.default\" title=\"django.db.models.Field.default\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">default</span></code></a> is specified on a model field.\nSimilarly, database defaults aren't translated to model field defaults or\ndetected in any fashion by <code class=\"docutils literal notranslate\"><span class=\"pre\">inspectdb</span></code>.</p>\n<p>By default, <code class=\"docutils literal notranslate\"><span class=\"pre\">inspectdb</span></code> creates unmanaged models. That is, <code class=\"docutils literal notranslate\"><span class=\"pre\">managed</span> <span class=\"pre\">=</span> <span class=\"pre\">False</span></code>\nin the model's <code class=\"docutils literal notranslate\"><span class=\"pre\">Meta</span></code> class tells Django not to manage each table's creation,\nmodification, and deletion. If you do want to allow Django to manage the\ntable's lifecycle, you'll need to change the\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/models/options/#django.db.models.Options.managed\" title=\"django.db.models.Options.managed\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">managed</span></code></a> option to <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code> (or simply remove\nit because <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code> is its default value).</p>\n<section id=\"database-specific-notes\">\n<h4>特定于数据库的注释<a class=\"heading-anchor\" href=\"#database-specific-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<section id=\"oracle\">\n<h5>Oracle<a class=\"heading-anchor\" href=\"#oracle\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<ul class=\"simple\">\n<li><p>Models are created for materialized views if <a class=\"reference internal\" href=\"#cmdoption-inspectdb-include-views\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--include-views</span></code></a> is\nused.</p></li>\n</ul>\n</section>\n<section id=\"postgresql\">\n<h5>PostgreSQL<a class=\"heading-anchor\" href=\"#postgresql\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<ul class=\"simple\">\n<li><p>Models are created for foreign tables.</p></li>\n<li><p>Models are created for materialized views if\n<a class=\"reference internal\" href=\"#cmdoption-inspectdb-include-views\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--include-views</span></code></a> is used.</p></li>\n<li><p>Models are created for partition tables if\n<a class=\"reference internal\" href=\"#cmdoption-inspectdb-include-partitions\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--include-partitions</span></code></a> is used.</p></li>\n</ul>\n<aside class=\"version-note version-changed\" data-version=\"2.2\">\n<p class=\"version-note-title\">Changed in Django 2.2</p><p>Support for foreign tables and materialized views was added.</p>\n</aside>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-inspectdb-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-inspectdb-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database to introspect. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-inspectdb-include-partitions\">\n<span class=\"sig-name descname\"><span class=\"pre\">--include-partitions</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-inspectdb-include-partitions\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<aside class=\"version-note version-added\" data-version=\"2.2\">\n<p class=\"version-note-title\">New in Django 2.2</p></aside>\n<p>If this option is provided, models are also created for partitions.</p>\n<p>Only support for PostgreSQL is implemented.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-inspectdb-include-views\">\n<span class=\"sig-name descname\"><span class=\"pre\">--include-views</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-inspectdb-include-views\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<aside class=\"version-note version-added\" data-version=\"2.1\">\n<p class=\"version-note-title\">New in Django 2.1</p></aside>\n<p>If this option is provided, models are also created for database views.</p>\n</section>\n</section>\n</section>\n<section id=\"loaddata\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">loaddata</span></code><a class=\"heading-anchor\" href=\"#loaddata\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-loaddata\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">loaddata</span> <span class=\"pre\">fixture</span> <span class=\"pre\">[fixture</span> <span class=\"pre\">...]</span></span><a class=\"heading-anchor\" href=\"#django-admin-loaddata\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Searches for and loads the contents of the named fixture into the database.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-loaddata-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-loaddata-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database into which the data will be loaded. Defaults to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-loaddata-ignorenonexistent\">\n<span id=\"cmdoption-loaddata-i\"></span><span class=\"sig-name descname\"><span class=\"pre\">--ignorenonexistent</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-i</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-loaddata-ignorenonexistent\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Ignores fields and models that may have been removed since the fixture was\noriginally generated.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-loaddata-app\">\n<span class=\"sig-name descname\"><span class=\"pre\">--app</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">APP_LABEL</span></span><a class=\"heading-anchor\" href=\"#cmdoption-loaddata-app\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies a single app to look for fixtures in rather than looking in all apps.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-loaddata-format\">\n<span class=\"sig-name descname\"><span class=\"pre\">--format</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">FORMAT</span></span><a class=\"heading-anchor\" href=\"#cmdoption-loaddata-format\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/serialization/#serialization-formats\"><span class=\"std std-ref\">serialization format</span></a> (e.g.,\n<code class=\"docutils literal notranslate\"><span class=\"pre\">json</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">xml</span></code>) for fixtures <a class=\"reference internal\" href=\"#loading-fixtures-stdin\"><span class=\"std std-ref\">read from stdin</span></a>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-loaddata-exclude\">\n<span id=\"cmdoption-loaddata-e\"></span><span class=\"sig-name descname\"><span class=\"pre\">--exclude</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXCLUDE</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-e</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXCLUDE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-loaddata-exclude\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Excludes loading the fixtures from the given applications and/or models (in the\nform of <code class=\"docutils literal notranslate\"><span class=\"pre\">app_label</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">app_label.ModelName</span></code>). Use the option multiple\ntimes to exclude more than one app or model.</p>\n<section id=\"what-s-a-fixture\">\n<h4>What's a &quot;fixture&quot;?<a class=\"heading-anchor\" href=\"#what-s-a-fixture\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>A <em>fixture</em> is a collection of files that contain the serialized contents of\nthe database. Each fixture has a unique name, and the files that comprise the\nfixture can be distributed over multiple directories, in multiple applications.</p>\n<p>Django will search in three locations for fixtures:</p>\n<ol class=\"arabic simple\">\n<li><p>In the <code class=\"docutils literal notranslate\"><span class=\"pre\">fixtures</span></code> directory of every installed application</p></li>\n<li><p>In any directory named in the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-FIXTURE_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">FIXTURE_DIRS</span></code></a> setting</p></li>\n<li><p>In the literal path named by the fixture</p></li>\n</ol>\n<p>Django will load any and all fixtures it finds in these locations that match\nthe provided fixture names.</p>\n<p>If the named fixture has a file extension, only fixtures of that type\nwill be loaded. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">loaddata</span> <span class=\"n\">mydata</span><span class=\"o\">.</span><span class=\"n\">json</span>\n</code></pre></div>\n<p>would only load JSON fixtures called <code class=\"docutils literal notranslate\"><span class=\"pre\">mydata</span></code>. The fixture extension\nmust correspond to the registered name of a\n<a class=\"reference internal\" href=\"/zh-hans/2.2/topics/serialization/#serialization-formats\"><span class=\"std std-ref\">serializer</span></a> (e.g., <code class=\"docutils literal notranslate\"><span class=\"pre\">json</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">xml</span></code>).</p>\n<p>If you omit the extensions, Django will search all available fixture types\nfor a matching fixture. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">loaddata</span> <span class=\"n\">mydata</span>\n</code></pre></div>\n<p>would look for any fixture of any fixture type called <code class=\"docutils literal notranslate\"><span class=\"pre\">mydata</span></code>. If a fixture\ndirectory contained <code class=\"docutils literal notranslate\"><span class=\"pre\">mydata.json</span></code>, that fixture would be loaded\nas a JSON fixture.</p>\n<p>The fixtures that are named can include directory components. These\ndirectories will be included in the search path. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">loaddata</span> <span class=\"n\">foo</span><span class=\"o\">/</span><span class=\"n\">bar</span><span class=\"o\">/</span><span class=\"n\">mydata</span><span class=\"o\">.</span><span class=\"n\">json</span>\n</code></pre></div>\n<p>would search <code class=\"docutils literal notranslate\"><span class=\"pre\">&lt;app_label&gt;/fixtures/foo/bar/mydata.json</span></code> for each installed\napplication,  <code class=\"docutils literal notranslate\"><span class=\"pre\">&lt;dirname&gt;/foo/bar/mydata.json</span></code> for each directory in\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-FIXTURE_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">FIXTURE_DIRS</span></code></a>, and the literal path <code class=\"docutils literal notranslate\"><span class=\"pre\">foo/bar/mydata.json</span></code>.</p>\n<p>When fixture files are processed, the data is saved to the database as is.\nModel defined <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/models/instances/#django.db.models.Model.save\" title=\"django.db.models.Model.save\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">save()</span></code></a> methods are not called, and\nany <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/signals/#django.db.models.signals.pre_save\" title=\"django.db.models.signals.pre_save\"><code class=\"xref py py-data docutils literal notranslate\"><span class=\"pre\">pre_save</span></code></a> or\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/signals/#django.db.models.signals.post_save\" title=\"django.db.models.signals.post_save\"><code class=\"xref py py-data docutils literal notranslate\"><span class=\"pre\">post_save</span></code></a> signals will be called with\n<code class=\"docutils literal notranslate\"><span class=\"pre\">raw=True</span></code> since the instance only contains attributes that are local to the\nmodel. You may, for example, want to disable handlers that access\nrelated fields that aren't present during fixture loading and would otherwise\nraise an exception:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.db.models.signals</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">post_save</span>\n<span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">.models</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">MyModel</span>\n\n<span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">my_handler</span><span class=\"p\">(</span><span class=\"o\">**</span><span class=\"n\">kwargs</span><span class=\"p\">):</span>\n    <span class=\"c1\"># disable the handler during fixture loading</span>\n    <span class=\"k\">if</span> <span class=\"n\">kwargs</span><span class=\"p\">[</span><span class=\"s1\">&#39;raw&#39;</span><span class=\"p\">]:</span>\n        <span class=\"k\">return</span>\n    <span class=\"o\">...</span>\n\n<span class=\"n\">post_save</span><span class=\"o\">.</span><span class=\"n\">connect</span><span class=\"p\">(</span><span class=\"n\">my_handler</span><span class=\"p\">,</span> <span class=\"n\">sender</span><span class=\"o\">=</span><span class=\"n\">MyModel</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>You could also write a simple decorator to encapsulate this logic:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">functools</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">wraps</span>\n\n<span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">disable_for_loaddata</span><span class=\"p\">(</span><span class=\"n\">signal_handler</span><span class=\"p\">):</span>\n<span class=\"w\">    </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Decorator that turns off signal handlers when loading fixture data.</span>\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n    <span class=\"nd\">@wraps</span><span class=\"p\">(</span><span class=\"n\">signal_handler</span><span class=\"p\">)</span>\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">wrapper</span><span class=\"p\">(</span><span class=\"o\">*</span><span class=\"n\">args</span><span class=\"p\">,</span> <span class=\"o\">**</span><span class=\"n\">kwargs</span><span class=\"p\">):</span>\n        <span class=\"k\">if</span> <span class=\"n\">kwargs</span><span class=\"p\">[</span><span class=\"s1\">&#39;raw&#39;</span><span class=\"p\">]:</span>\n            <span class=\"k\">return</span>\n        <span class=\"n\">signal_handler</span><span class=\"p\">(</span><span class=\"o\">*</span><span class=\"n\">args</span><span class=\"p\">,</span> <span class=\"o\">**</span><span class=\"n\">kwargs</span><span class=\"p\">)</span>\n    <span class=\"k\">return</span> <span class=\"n\">wrapper</span>\n\n<span class=\"nd\">@disable_for_loaddata</span>\n<span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">my_handler</span><span class=\"p\">(</span><span class=\"o\">**</span><span class=\"n\">kwargs</span><span class=\"p\">):</span>\n    <span class=\"o\">...</span>\n</code></pre></div>\n<p>Just be aware that this logic will disable the signals whenever fixtures are\ndeserialized, not just during <code class=\"docutils literal notranslate\"><span class=\"pre\">loaddata</span></code>.</p>\n<p>Note that the order in which fixture files are processed is undefined. However,\nall fixture data is installed as a single transaction, so data in\none fixture can reference data in another fixture. If the database backend\nsupports row-level constraints, these constraints will be checked at the\nend of the transaction.</p>\n<p>The <a class=\"reference internal\" href=\"#django-admin-dumpdata\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">dumpdata</span></code></a> command can be used to generate input for <code class=\"docutils literal notranslate\"><span class=\"pre\">loaddata</span></code>.</p>\n</section>\n<section id=\"compressed-fixtures\">\n<h4>Compressed fixtures<a class=\"heading-anchor\" href=\"#compressed-fixtures\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Fixtures may be compressed in <code class=\"docutils literal notranslate\"><span class=\"pre\">zip</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">gz</span></code>, or <code class=\"docutils literal notranslate\"><span class=\"pre\">bz2</span></code> format. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">loaddata</span> <span class=\"n\">mydata</span><span class=\"o\">.</span><span class=\"n\">json</span>\n</code></pre></div>\n<p>would look for any of <code class=\"docutils literal notranslate\"><span class=\"pre\">mydata.json</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">mydata.json.zip</span></code>,\n<code class=\"docutils literal notranslate\"><span class=\"pre\">mydata.json.gz</span></code>, or <code class=\"docutils literal notranslate\"><span class=\"pre\">mydata.json.bz2</span></code>. The first file contained within a\nzip-compressed archive is used.</p>\n<p>Note that if two fixtures with the same name but different\nfixture type are discovered (for example, if <code class=\"docutils literal notranslate\"><span class=\"pre\">mydata.json</span></code> and\n<code class=\"docutils literal notranslate\"><span class=\"pre\">mydata.xml.gz</span></code> were found in the same fixture directory), fixture\ninstallation will be aborted, and any data installed in the call to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">loaddata</span></code> will be removed from the database.</p>\n<aside class=\"admonition-mysql-with-myisam-and-fixtures admonition\">\n<p class=\"admonition-title\">MySQL with MyISAM and fixtures</p>\n<p>The MyISAM storage engine of MySQL doesn't support transactions or\nconstraints, so if you use MyISAM, you won't get validation of fixture\ndata, or a rollback if multiple transaction files are found.</p>\n</aside>\n</section>\n<section id=\"database-specific-fixtures\">\n<h4>Database-specific fixtures<a class=\"heading-anchor\" href=\"#database-specific-fixtures\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>If you're in a multi-database setup, you might have fixture data that\nyou want to load onto one database, but not onto another. In this\nsituation, you can add a database identifier into the names of your fixtures.</p>\n<p>For example, if your <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-DATABASES\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DATABASES</span></code></a> setting has a 'master' database\ndefined, name the fixture <code class=\"docutils literal notranslate\"><span class=\"pre\">mydata.master.json</span></code> or\n<code class=\"docutils literal notranslate\"><span class=\"pre\">mydata.master.json.gz</span></code> and the fixture will only be loaded when you\nspecify you want to load data into the <code class=\"docutils literal notranslate\"><span class=\"pre\">master</span></code> database.</p>\n</section>\n<section id=\"loading-fixtures-from-stdin\">\n<span id=\"loading-fixtures-stdin\"></span><h4>Loading fixtures from <code class=\"docutils literal notranslate\"><span class=\"pre\">stdin</span></code><a class=\"heading-anchor\" href=\"#loading-fixtures-from-stdin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>You can use a dash as the fixture name to load input from <code class=\"docutils literal notranslate\"><span class=\"pre\">sys.stdin</span></code>. For\nexample:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">loaddata</span> <span class=\"o\">--</span><span class=\"nb\">format</span><span class=\"o\">=</span><span class=\"n\">json</span> <span class=\"o\">-</span>\n</code></pre></div>\n<p>When reading from <code class=\"docutils literal notranslate\"><span class=\"pre\">stdin</span></code>, the <a class=\"reference internal\" href=\"#cmdoption-loaddata-format\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--format</span></code></a> option\nis required to specify the <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/serialization/#serialization-formats\"><span class=\"std std-ref\">serialization format</span></a>\nof the input (e.g., <code class=\"docutils literal notranslate\"><span class=\"pre\">json</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">xml</span></code>).</p>\n<p>Loading from <code class=\"docutils literal notranslate\"><span class=\"pre\">stdin</span></code> is useful with standard input and output redirections.\nFor example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">dumpdata</span> <span class=\"o\">--</span><span class=\"nb\">format</span><span class=\"o\">=</span><span class=\"n\">json</span> <span class=\"o\">--</span><span class=\"n\">database</span><span class=\"o\">=</span><span class=\"n\">test</span> <span class=\"n\">app_label</span><span class=\"o\">.</span><span class=\"n\">ModelName</span> <span class=\"o\">|</span> <span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">loaddata</span> <span class=\"o\">--</span><span class=\"nb\">format</span><span class=\"o\">=</span><span class=\"n\">json</span> <span class=\"o\">--</span><span class=\"n\">database</span><span class=\"o\">=</span><span class=\"n\">prod</span> <span class=\"o\">-</span>\n</code></pre></div>\n</section>\n</section>\n<section id=\"makemessages\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">makemessages</span></code><a class=\"heading-anchor\" href=\"#makemessages\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-makemessages\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">makemessages</span></span><a class=\"heading-anchor\" href=\"#django-admin-makemessages\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Runs over the entire source tree of the current directory and pulls out all\nstrings marked for translation. It creates (or updates) a message file in the\nconf/locale (in the Django tree) or locale (for project and application)\ndirectory. After making changes to the messages files you need to compile them\nwith <a class=\"reference internal\" href=\"#django-admin-compilemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">compilemessages</span></code></a> for use with the builtin gettext support. See\nthe <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/i18n/translation/#how-to-create-language-files\"><span class=\"std std-ref\">i18n documentation</span></a> for details.</p>\n<p>This command doesn't require configured settings. However, when settings aren't\nconfigured, the command can't ignore the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MEDIA_ROOT</span></code></a> and\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_ROOT</span></code></a> directories or include <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-LOCALE_PATHS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">LOCALE_PATHS</span></code></a>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-all\">\n<span id=\"cmdoption-makemessages-a\"></span><span class=\"sig-name descname\"><span class=\"pre\">--all</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-a</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-all\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Updates the message files for all available languages.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-extension\">\n<span id=\"cmdoption-makemessages-e\"></span><span class=\"sig-name descname\"><span class=\"pre\">--extension</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXTENSIONS</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-e</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXTENSIONS</span></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-extension\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies a list of file extensions to examine (default: <code class=\"docutils literal notranslate\"><span class=\"pre\">html</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">txt</span></code>,\n<code class=\"docutils literal notranslate\"><span class=\"pre\">py</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">js</span></code> if <a class=\"reference internal\" href=\"#cmdoption-makemessages-domain\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--domain</span></code></a> is <code class=\"docutils literal notranslate\"><span class=\"pre\">js</span></code>).</p>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">--</span><span class=\"n\">locale</span><span class=\"o\">=</span><span class=\"n\">de</span> <span class=\"o\">--</span><span class=\"n\">extension</span> <span class=\"n\">xhtml</span>\n</code></pre></div>\n<p>Separate multiple extensions with commas or use <code class=\"docutils literal notranslate\"><span class=\"pre\">-e</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">--extension</span></code>\nmultiple times:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">--</span><span class=\"n\">locale</span><span class=\"o\">=</span><span class=\"n\">de</span> <span class=\"o\">--</span><span class=\"n\">extension</span><span class=\"o\">=</span><span class=\"n\">html</span><span class=\"p\">,</span><span class=\"n\">txt</span> <span class=\"o\">--</span><span class=\"n\">extension</span> <span class=\"n\">xml</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-locale\">\n<span id=\"cmdoption-makemessages-l\"></span><span class=\"sig-name descname\"><span class=\"pre\">--locale</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">LOCALE</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-l</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">LOCALE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-locale\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the locale(s) to process.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-exclude\">\n<span id=\"cmdoption-makemessages-x\"></span><span class=\"sig-name descname\"><span class=\"pre\">--exclude</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXCLUDE</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-x</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXCLUDE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-exclude\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the locale(s) to exclude from processing. If not provided, no locales\nare excluded.</p>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">--</span><span class=\"n\">locale</span><span class=\"o\">=</span><span class=\"n\">pt_BR</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">--</span><span class=\"n\">locale</span><span class=\"o\">=</span><span class=\"n\">pt_BR</span> <span class=\"o\">--</span><span class=\"n\">locale</span><span class=\"o\">=</span><span class=\"n\">fr</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">-</span><span class=\"n\">l</span> <span class=\"n\">pt_BR</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">-</span><span class=\"n\">l</span> <span class=\"n\">pt_BR</span> <span class=\"o\">-</span><span class=\"n\">l</span> <span class=\"n\">fr</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">--</span><span class=\"n\">exclude</span><span class=\"o\">=</span><span class=\"n\">pt_BR</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">--</span><span class=\"n\">exclude</span><span class=\"o\">=</span><span class=\"n\">pt_BR</span> <span class=\"o\">--</span><span class=\"n\">exclude</span><span class=\"o\">=</span><span class=\"n\">fr</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">-</span><span class=\"n\">x</span> <span class=\"n\">pt_BR</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">-</span><span class=\"n\">x</span> <span class=\"n\">pt_BR</span> <span class=\"o\">-</span><span class=\"n\">x</span> <span class=\"n\">fr</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-domain\">\n<span id=\"cmdoption-makemessages-d\"></span><span class=\"sig-name descname\"><span class=\"pre\">--domain</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DOMAIN</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-d</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DOMAIN</span></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-domain\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the domain of the messages files. Supported options are:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">django</span></code> for all <code class=\"docutils literal notranslate\"><span class=\"pre\">*.py</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">*.html</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">*.txt</span></code> files (default)</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">djangojs</span></code> for <code class=\"docutils literal notranslate\"><span class=\"pre\">*.js</span></code> files</p></li>\n</ul>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-symlinks\">\n<span id=\"cmdoption-makemessages-s\"></span><span class=\"sig-name descname\"><span class=\"pre\">--symlinks</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-s</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-symlinks\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Follows symlinks to directories when looking for new translation strings.</p>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">--</span><span class=\"n\">locale</span><span class=\"o\">=</span><span class=\"n\">de</span> <span class=\"o\">--</span><span class=\"n\">symlinks</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-ignore\">\n<span id=\"cmdoption-makemessages-i\"></span><span class=\"sig-name descname\"><span class=\"pre\">--ignore</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">PATTERN</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-i</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">PATTERN</span></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-ignore\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Ignores files or directories matching the given <a class=\"reference external\" href=\"https://docs.python.org/3/library/glob.html#module-glob\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">glob</span></code></a>-style pattern. Use\nmultiple times to ignore more.</p>\n<p>These patterns are used by default: <code class=\"docutils literal notranslate\"><span class=\"pre\">'CVS'</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">'.*'</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">'*~'</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">'*.pyc'</span></code>.</p>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">makemessages</span> <span class=\"o\">--</span><span class=\"n\">locale</span><span class=\"o\">=</span><span class=\"n\">en_US</span> <span class=\"o\">--</span><span class=\"n\">ignore</span><span class=\"o\">=</span><span class=\"n\">apps</span><span class=\"o\">/*</span> <span class=\"o\">--</span><span class=\"n\">ignore</span><span class=\"o\">=</span><span class=\"n\">secret</span><span class=\"o\">/*.</span><span class=\"n\">html</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-no-default-ignore\">\n<span class=\"sig-name descname\"><span class=\"pre\">--no-default-ignore</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-no-default-ignore\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Disables the default values of <code class=\"docutils literal notranslate\"><span class=\"pre\">--ignore</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-no-wrap\">\n<span class=\"sig-name descname\"><span class=\"pre\">--no-wrap</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-no-wrap\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Disables breaking long message lines into several lines in language files.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-no-location\">\n<span class=\"sig-name descname\"><span class=\"pre\">--no-location</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-no-location\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Suppresses writing '<code class=\"docutils literal notranslate\"><span class=\"pre\">#:</span> <span class=\"pre\">filename:line</span></code>’ comment lines in language files.\nUsing this option makes it harder for technically skilled translators to\nunderstand each message's context.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-add-location\">\n<span class=\"sig-name descname\"><span class=\"pre\">--add-location</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">[{full,file,never}]</span></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-add-location\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Controls <code class=\"docutils literal notranslate\"><span class=\"pre\">#:</span> <span class=\"pre\">filename:line</span></code> comment lines in language files. If the option\nis:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">full</span></code> (the default if not given): the lines include both file name and\nline number.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">file</span></code>: the line number is omitted.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">never</span></code>: the lines are suppressed (same as <a class=\"reference internal\" href=\"#cmdoption-makemessages-no-location\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--no-location</span></code></a>).</p></li>\n</ul>\n<p>Requires <code class=\"docutils literal notranslate\"><span class=\"pre\">gettext</span></code> 0.19 or newer.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemessages-keep-pot\">\n<span class=\"sig-name descname\"><span class=\"pre\">--keep-pot</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemessages-keep-pot\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Prevents deleting the temporary <code class=\"docutils literal notranslate\"><span class=\"pre\">.pot</span></code> files generated before creating the\n<code class=\"docutils literal notranslate\"><span class=\"pre\">.po</span></code> file. This is useful for debugging errors which may prevent the final\nlanguage files from being created.</p>\n<aside class=\"admonition admonition-seealso\">\n<p class=\"admonition-title\">See also</p>\n<p>See <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/i18n/translation/#customizing-makemessages\"><span class=\"std std-ref\">Customizing the makemessages command</span></a> for instructions on how to customize\nthe keywords that <a class=\"reference internal\" href=\"#django-admin-makemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">makemessages</span></code></a> passes to <code class=\"docutils literal notranslate\"><span class=\"pre\">xgettext</span></code>.</p>\n</aside>\n</section>\n<section id=\"makemigrations\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">makemigrations</span></code><a class=\"heading-anchor\" href=\"#makemigrations\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-makemigrations\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">makemigrations</span> <span class=\"pre\">[app_label</span> <span class=\"pre\">[app_label</span> <span class=\"pre\">...]]</span></span><a class=\"heading-anchor\" href=\"#django-admin-makemigrations\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Creates new migrations based on the changes detected to your models.\nMigrations, their relationship with apps and more are covered in depth in\n<a class=\"reference internal\" href=\"/zh-hans/2.2/topics/migrations/\"><span class=\"doc\">the migrations documentation</span></a>.</p>\n<p>Providing one or more app names as arguments will limit the migrations created\nto the app(s) specified and any dependencies needed (the table at the other end\nof a <code class=\"docutils literal notranslate\"><span class=\"pre\">ForeignKey</span></code>, for example).</p>\n<p>To add migrations to an app that doesn't have a <code class=\"docutils literal notranslate\"><span class=\"pre\">migrations</span></code> directory, run\n<code class=\"docutils literal notranslate\"><span class=\"pre\">makemigrations</span></code> with the app's <code class=\"docutils literal notranslate\"><span class=\"pre\">app_label</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemigrations-noinput\">\n<span id=\"cmdoption-makemigrations-no-input\"></span><span class=\"sig-name descname\"><span class=\"pre\">--noinput</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">--no-input</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemigrations-noinput\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Suppresses all user prompts. If a suppressed prompt cannot be resolved\nautomatically, the command will exit with error code 3.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemigrations-empty\">\n<span class=\"sig-name descname\"><span class=\"pre\">--empty</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemigrations-empty\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Outputs an empty migration for the specified apps, for manual editing. This is\nfor advanced users and should not be used unless you are familiar with the\nmigration format, migration operations, and the dependencies between your\nmigrations.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemigrations-dry-run\">\n<span class=\"sig-name descname\"><span class=\"pre\">--dry-run</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemigrations-dry-run\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Shows what migrations would be made without actually writing any migrations\nfiles to disk. Using this option along with <code class=\"docutils literal notranslate\"><span class=\"pre\">--verbosity</span> <span class=\"pre\">3</span></code> will also show\nthe complete migrations files that would be written.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemigrations-merge\">\n<span class=\"sig-name descname\"><span class=\"pre\">--merge</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemigrations-merge\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Enables fixing of migration conflicts.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemigrations-name\">\n<span id=\"cmdoption-makemigrations-n\"></span><span class=\"sig-name descname\"><span class=\"pre\">--name</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">NAME</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-n</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">NAME</span></span><a class=\"heading-anchor\" href=\"#cmdoption-makemigrations-name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Allows naming the generated migration(s) instead of using a generated name. The\nname must be a valid Python <a class=\"reference external\" href=\"https://docs.python.org/3/reference/lexical_analysis.html#identifiers\" title=\"(in Python v3.14)\"><span class=\"xref std std-ref\">identifier</span></a>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemigrations-no-header\">\n<span class=\"sig-name descname\"><span class=\"pre\">--no-header</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemigrations-no-header\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<aside class=\"version-note version-added\" data-version=\"2.2\">\n<p class=\"version-note-title\">New in Django 2.2</p></aside>\n<p>Generate migration files without Django version and timestamp header.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-makemigrations-check\">\n<span class=\"sig-name descname\"><span class=\"pre\">--check</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-makemigrations-check\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Makes <code class=\"docutils literal notranslate\"><span class=\"pre\">makemigrations</span></code> exit with a non-zero status when model changes without\nmigrations are detected.</p>\n</section>\n<section id=\"migrate\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">migrate</span></code><a class=\"heading-anchor\" href=\"#migrate\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-migrate\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">migrate</span> <span class=\"pre\">[app_label]</span> <span class=\"pre\">[migration_name]</span></span><a class=\"heading-anchor\" href=\"#django-admin-migrate\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Synchronizes the database state with the current set of models and migrations.\nMigrations, their relationship with apps and more are covered in depth in\n<a class=\"reference internal\" href=\"/zh-hans/2.2/topics/migrations/\"><span class=\"doc\">the migrations documentation</span></a>.</p>\n<p>The behavior of this command changes depending on the arguments provided:</p>\n<ul class=\"simple\">\n<li><p>No arguments: All apps have all of their migrations run.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">&lt;app_label&gt;</span></code>: The specified app has its migrations run, up to the most\nrecent migration. This may involve running other apps' migrations too, due\nto dependencies.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">&lt;app_label&gt;</span> <span class=\"pre\">&lt;migrationname&gt;</span></code>: Brings the database schema to a state where\nthe named migration is applied, but no later migrations in the same app are\napplied. This may involve unapplying migrations if you have previously\nmigrated past the named migration. You can use a prefix of the migration\nname, e.g. <code class=\"docutils literal notranslate\"><span class=\"pre\">0001</span></code>, as long as it's unique for the given app name. Use the\nname <code class=\"docutils literal notranslate\"><span class=\"pre\">zero</span></code> to migrate all the way back i.e. to revert all applied\nmigrations for an app.</p></li>\n</ul>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Warning</p>\n<p>When unapplying migrations, all dependent migrations will also be\nunapplied, regardless of <code class=\"docutils literal notranslate\"><span class=\"pre\">&lt;app_label&gt;</span></code>. You can use <code class=\"docutils literal notranslate\"><span class=\"pre\">--plan</span></code> to check\nwhich migrations will be unapplied.</p>\n</aside>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-migrate-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-migrate-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database to migrate. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-migrate-fake\">\n<span class=\"sig-name descname\"><span class=\"pre\">--fake</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-migrate-fake\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Marks the migrations up to the target one (following the rules above) as\napplied, but without actually running the SQL to change your database schema.</p>\n<p>This is intended for advanced users to manipulate the\ncurrent migration state directly if they're manually applying changes;\nbe warned that using <code class=\"docutils literal notranslate\"><span class=\"pre\">--fake</span></code> runs the risk of putting the migration state\ntable into a state where manual recovery will be needed to make migrations\nrun correctly.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-migrate-fake-initial\">\n<span class=\"sig-name descname\"><span class=\"pre\">--fake-initial</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-migrate-fake-initial\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Allows Django to skip an app's initial migration if all database tables with\nthe names of all models created by all\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/migration-operations/#django.db.migrations.operations.CreateModel\" title=\"django.db.migrations.operations.CreateModel\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">CreateModel</span></code></a> operations in that\nmigration already exist. This option is intended for use when first running\nmigrations against a database that preexisted the use of migrations. This\noption does not, however, check for matching database schema beyond matching\ntable names and so is only safe to use if you are confident that your existing\nschema matches what is recorded in your initial migration.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-migrate-plan\">\n<span class=\"sig-name descname\"><span class=\"pre\">--plan</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-migrate-plan\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<aside class=\"version-note version-added\" data-version=\"2.2\">\n<p class=\"version-note-title\">New in Django 2.2</p></aside>\n<p>Shows the migration operations that will be performed for the given <code class=\"docutils literal notranslate\"><span class=\"pre\">migrate</span></code>\ncommand.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-migrate-run-syncdb\">\n<span class=\"sig-name descname\"><span class=\"pre\">--run-syncdb</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-migrate-run-syncdb\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Allows creating tables for apps without migrations. While this isn't\nrecommended, the migrations framework is sometimes too slow on large projects\nwith hundreds of models.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-migrate-noinput\">\n<span id=\"cmdoption-migrate-no-input\"></span><span class=\"sig-name descname\"><span class=\"pre\">--noinput</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">--no-input</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-migrate-noinput\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Suppresses all user prompts. An example prompt is asking about removing stale\ncontent types.</p>\n</section>\n<section id=\"runserver\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">runserver</span></code><a class=\"heading-anchor\" href=\"#runserver\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-runserver\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">runserver</span> <span class=\"pre\">[addrport]</span></span><a class=\"heading-anchor\" href=\"#django-admin-runserver\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Starts a lightweight development Web server on the local machine. By default,\nthe server runs on port 8000 on the IP address <code class=\"docutils literal notranslate\"><span class=\"pre\">127.0.0.1</span></code>. You can pass in an\nIP address and port number explicitly.</p>\n<p>If you run this script as a user with normal privileges (recommended), you\nmight not have access to start a port on a low port number. Low port numbers\nare reserved for the superuser (root).</p>\n<p>This server uses the WSGI application object specified by the\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-WSGI_APPLICATION\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">WSGI_APPLICATION</span></code></a> setting.</p>\n<p>DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through\nsecurity audits or performance tests. (And that's how it's gonna stay. We're in\nthe business of making Web frameworks, not Web servers, so improving this\nserver to be able to handle a production environment is outside the scope of\nDjango.)</p>\n<p>The development server automatically reloads Python code for each request, as\nneeded. You don't need to restart the server for code changes to take effect.\nHowever, some actions like adding files don't trigger a restart, so you'll\nhave to restart the server in these cases.</p>\n<p>If you're using Linux or MacOS and install both <a class=\"reference external\" href=\"https://pypi.org/project/pywatchman/\">pywatchman</a> and the\n<a class=\"reference external\" href=\"https://facebook.github.io/watchman/\">Watchman</a> service, kernel signals will be used to autoreload the server\n(rather than polling file modification timestamps each second). This offers\nbetter performance on large projects, reduced response time after code changes,\nmore robust change detection, and a reduction in power usage.</p>\n<aside class=\"admonition-large-directories-with-many-files-may-cause-performance-issues admonition\">\n<p class=\"admonition-title\">Large directories with many files may cause performance issues</p>\n<p>When using Watchman with a project that includes large non-Python\ndirectories like <code class=\"docutils literal notranslate\"><span class=\"pre\">node_modules</span></code>, it's advisable to ignore this directory\nfor optimal performance. See the <a class=\"reference external\" href=\"https://facebook.github.io/watchman/docs/config.html#ignore_dirs\">watchman documentation</a> for information\non how to do this.</p>\n</aside>\n<aside class=\"admonition-watchman-timeout admonition\">\n<p class=\"admonition-title\">Watchman timeout</p>\n<p>The default timeout of <code class=\"docutils literal notranslate\"><span class=\"pre\">Watchman</span></code> client is 5 seconds. You can change it\nby setting the <code class=\"docutils literal notranslate\"><span class=\"pre\">DJANGO_WATCHMAN_TIMEOUT</span></code> environment variable.</p>\n</aside>\n<aside class=\"version-note version-changed\" data-version=\"2.2\">\n<p class=\"version-note-title\">Changed in Django 2.2</p><p>Watchman support replaced support for pyinotify.</p>\n</aside>\n<p>When you start the server, and each time you change Python code while the\nserver is running, the system check framework will check your entire Django\nproject for some common errors (see the <a class=\"reference internal\" href=\"#django-admin-check\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">check</span></code></a> command). If any\nerrors are found, they will be printed to standard output.</p>\n<p>You can run as many concurrent servers as you want, as long as they're on\nseparate ports. Just execute <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span> <span class=\"pre\">runserver</span></code> more than once.</p>\n<p>Note that the default IP address, <code class=\"docutils literal notranslate\"><span class=\"pre\">127.0.0.1</span></code>, is not accessible from other\nmachines on your network. To make your development server viewable to other\nmachines on the network, use its own IP address (e.g. <code class=\"docutils literal notranslate\"><span class=\"pre\">192.168.2.1</span></code>) or\n<code class=\"docutils literal notranslate\"><span class=\"pre\">0.0.0.0</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">::</span></code> (with IPv6 enabled).</p>\n<p>You can provide an IPv6 address surrounded by brackets\n(e.g. <code class=\"docutils literal notranslate\"><span class=\"pre\">[200a::1]:8000</span></code>). This will automatically enable IPv6 support.</p>\n<p>A hostname containing ASCII-only characters can also be used.</p>\n<p>If the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> contrib app is enabled\n(default in new projects) the <a class=\"reference internal\" href=\"#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">runserver</span></code></a> command will be overridden\nwith its own <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/staticfiles/#staticfiles-runserver\"><span class=\"std std-ref\">runserver</span></a> command.</p>\n<p>Logging of each request and response of the server is sent to the\n<a class=\"reference internal\" href=\"/zh-hans/2.2/topics/logging/#django-server-logger\"><span class=\"std std-ref\">django.server</span></a> logger.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-runserver-noreload\">\n<span class=\"sig-name descname\"><span class=\"pre\">--noreload</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-runserver-noreload\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Disables the auto-reloader. This means any Python code changes you make while\nthe server is running will <em>not</em> take effect if the particular Python modules\nhave already been loaded into memory.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-runserver-nothreading\">\n<span class=\"sig-name descname\"><span class=\"pre\">--nothreading</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-runserver-nothreading\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Disables use of threading in the development server. The server is\nmultithreaded by default.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-runserver-ipv6\">\n<span id=\"cmdoption-runserver-6\"></span><span class=\"sig-name descname\"><span class=\"pre\">--ipv6</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-6</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-runserver-ipv6\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Uses IPv6 for the development server. This changes the default IP address from\n<code class=\"docutils literal notranslate\"><span class=\"pre\">127.0.0.1</span></code> to <code class=\"docutils literal notranslate\"><span class=\"pre\">::1</span></code>.</p>\n<section id=\"examples-of-using-different-ports-and-addresses\">\n<h4>Examples of using different ports and addresses<a class=\"heading-anchor\" href=\"#examples-of-using-different-ports-and-addresses\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Port 8000 on IP address <code class=\"docutils literal notranslate\"><span class=\"pre\">127.0.0.1</span></code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">runserver</span>\n</code></pre></div>\n<p>Port 8000 on IP address <code class=\"docutils literal notranslate\"><span class=\"pre\">1.2.3.4</span></code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">runserver</span> <span class=\"mf\">1.2.3.4</span><span class=\"p\">:</span><span class=\"mi\">8000</span>\n</code></pre></div>\n<p>Port 7000 on IP address <code class=\"docutils literal notranslate\"><span class=\"pre\">127.0.0.1</span></code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">runserver</span> <span class=\"mi\">7000</span>\n</code></pre></div>\n<p>Port 7000 on IP address <code class=\"docutils literal notranslate\"><span class=\"pre\">1.2.3.4</span></code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">runserver</span> <span class=\"mf\">1.2.3.4</span><span class=\"p\">:</span><span class=\"mi\">7000</span>\n</code></pre></div>\n<p>Port 8000 on IPv6 address <code class=\"docutils literal notranslate\"><span class=\"pre\">::1</span></code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">runserver</span> <span class=\"o\">-</span><span class=\"mi\">6</span>\n</code></pre></div>\n<p>Port 7000 on IPv6 address <code class=\"docutils literal notranslate\"><span class=\"pre\">::1</span></code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">runserver</span> <span class=\"o\">-</span><span class=\"mi\">6</span> <span class=\"mi\">7000</span>\n</code></pre></div>\n<p>Port 7000 on IPv6 address <code class=\"docutils literal notranslate\"><span class=\"pre\">2001:0db8:1234:5678::9</span></code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">runserver</span> <span class=\"p\">[</span><span class=\"mi\">2001</span><span class=\"p\">:</span><span class=\"mi\">0</span><span class=\"n\">db8</span><span class=\"p\">:</span><span class=\"mi\">1234</span><span class=\"p\">:</span><span class=\"mi\">5678</span><span class=\"p\">::</span><span class=\"mi\">9</span><span class=\"p\">]:</span><span class=\"mi\">7000</span>\n</code></pre></div>\n<p>Port 8000 on IPv4 address of host <code class=\"docutils literal notranslate\"><span class=\"pre\">localhost</span></code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">runserver</span> <span class=\"n\">localhost</span><span class=\"p\">:</span><span class=\"mi\">8000</span>\n</code></pre></div>\n<p>Port 8000 on IPv6 address of host <code class=\"docutils literal notranslate\"><span class=\"pre\">localhost</span></code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">runserver</span> <span class=\"o\">-</span><span class=\"mi\">6</span> <span class=\"n\">localhost</span><span class=\"p\">:</span><span class=\"mi\">8000</span>\n</code></pre></div>\n</section>\n<section id=\"serving-static-files-with-the-development-server\">\n<h4>Serving static files with the development server<a class=\"heading-anchor\" href=\"#serving-static-files-with-the-development-server\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>By default, the development server doesn't serve any static files for your site\n(such as CSS files, images, things under <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-MEDIA_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MEDIA_URL</span></code></a> and so forth). If\nyou want to configure Django to serve static media, read\n<a class=\"reference internal\" href=\"/zh-hans/2.2/howto/static-files/\"><span class=\"doc\">管理静态文件（比如图片、JavaScript、CSS）</span></a>.</p>\n</section>\n</section>\n<section id=\"sendtestemail\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">sendtestemail</span></code><a class=\"heading-anchor\" href=\"#sendtestemail\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-sendtestemail\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">sendtestemail</span> <span class=\"pre\">[email</span> <span class=\"pre\">[email</span> <span class=\"pre\">...]]</span></span><a class=\"heading-anchor\" href=\"#django-admin-sendtestemail\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Sends a test email (to confirm email sending through Django is working) to the\nrecipient(s) specified. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">sendtestemail</span> <span class=\"n\">foo</span><span class=\"nd\">@example</span><span class=\"o\">.</span><span class=\"n\">com</span> <span class=\"n\">bar</span><span class=\"nd\">@example</span><span class=\"o\">.</span><span class=\"n\">com</span>\n</code></pre></div>\n<p>There are a couple of options, and you may use any combination of them\ntogether:</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-sendtestemail-managers\">\n<span class=\"sig-name descname\"><span class=\"pre\">--managers</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-sendtestemail-managers\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Mails the email addresses specified in <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-MANAGERS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MANAGERS</span></code></a> using\n<a class=\"reference internal\" href=\"/zh-hans/2.2/topics/email/#django.core.mail.mail_managers\" title=\"django.core.mail.mail_managers\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">mail_managers()</span></code></a>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-sendtestemail-admins\">\n<span class=\"sig-name descname\"><span class=\"pre\">--admins</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-sendtestemail-admins\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Mails the email addresses specified in <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-ADMINS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ADMINS</span></code></a> using\n<a class=\"reference internal\" href=\"/zh-hans/2.2/topics/email/#django.core.mail.mail_admins\" title=\"django.core.mail.mail_admins\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">mail_admins()</span></code></a>.</p>\n</section>\n<section id=\"shell\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">shell</span></code><a class=\"heading-anchor\" href=\"#shell\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-shell\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">shell</span></span><a class=\"heading-anchor\" href=\"#django-admin-shell\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Starts the Python interactive interpreter.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-shell-interface\">\n<span id=\"cmdoption-shell-i\"></span><span class=\"sig-name descname\"><span class=\"pre\">--interface</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">{ipython,bpython,python}</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-i</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">{ipython,bpython,python}</span></span><a class=\"heading-anchor\" href=\"#cmdoption-shell-interface\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the shell to use. By default, Django will use <a class=\"reference external\" href=\"https://ipython.org/\">IPython</a> or <a class=\"reference external\" href=\"https://bpython-interpreter.org/\">bpython</a> if\neither is installed. If both are installed, specify which one you want like so:</p>\n<p>IPython:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">shell</span> <span class=\"o\">-</span><span class=\"n\">i</span> <span class=\"n\">ipython</span>\n</code></pre></div>\n<p>bpython:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">shell</span> <span class=\"o\">-</span><span class=\"n\">i</span> <span class=\"n\">bpython</span>\n</code></pre></div>\n<p>If you have a &quot;rich&quot; shell installed but want to force use of the &quot;plain&quot;\nPython interpreter, use <code class=\"docutils literal notranslate\"><span class=\"pre\">python</span></code> as the interface name, like so:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">shell</span> <span class=\"o\">-</span><span class=\"n\">i</span> <span class=\"n\">python</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-shell-nostartup\">\n<span class=\"sig-name descname\"><span class=\"pre\">--nostartup</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-shell-nostartup\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Disables reading the startup script for the &quot;plain&quot; Python interpreter. By\ndefault, the script pointed to by the <span class=\"target\" id=\"index-3\"></span><a class=\"reference external\" href=\"https://docs.python.org/3/using/cmdline.html#envvar-PYTHONSTARTUP\" title=\"(in Python v3.14)\"><code class=\"xref std std-envvar docutils literal notranslate\"><span class=\"pre\">PYTHONSTARTUP</span></code></a> environment\nvariable or the <code class=\"docutils literal notranslate\"><span class=\"pre\">~/.pythonrc.py</span></code> script is read.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-shell-command\">\n<span id=\"cmdoption-shell-c\"></span><span class=\"sig-name descname\"><span class=\"pre\">--command</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">COMMAND</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-c</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">COMMAND</span></span><a class=\"heading-anchor\" href=\"#cmdoption-shell-command\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Lets you pass a command as a string to execute it as Django, like so:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">shell</span> <span class=\"o\">--</span><span class=\"n\">command</span><span class=\"o\">=</span><span class=\"s2\">&quot;import django; print(django.__version__)&quot;</span>\n</code></pre></div>\n<p>You can also pass code in on standard input to execute it. For example:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>django-admin<span class=\"w\"> </span>shell<span class=\"w\"> </span>&lt;&lt;EOF\n<span class=\"go\">&gt; import django</span>\n<span class=\"go\">&gt; print(django.__version__)</span>\n<span class=\"go\">&gt; EOF</span>\n</code></pre></div>\n<p>On Windows, the REPL is output due to implementation limits of\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/select.html#select.select\" title=\"(in Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">select.select()</span></code></a> on that platform.</p>\n</section>\n<section id=\"showmigrations\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">showmigrations</span></code><a class=\"heading-anchor\" href=\"#showmigrations\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-showmigrations\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">showmigrations</span> <span class=\"pre\">[app_label</span> <span class=\"pre\">[app_label</span> <span class=\"pre\">...]]</span></span><a class=\"heading-anchor\" href=\"#django-admin-showmigrations\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Shows all migrations in a project. You can choose from one of two formats:</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-showmigrations-list\">\n<span id=\"cmdoption-showmigrations-l\"></span><span class=\"sig-name descname\"><span class=\"pre\">--list</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-l</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-showmigrations-list\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Lists all of the apps Django knows about, the migrations available for each\napp, and whether or not each migration is applied (marked by an <code class=\"docutils literal notranslate\"><span class=\"pre\">[X]</span></code> next to\nthe migration name).</p>\n<p>Apps without migrations are also listed, but have <code class=\"docutils literal notranslate\"><span class=\"pre\">(no</span> <span class=\"pre\">migrations)</span></code> printed\nunder them.</p>\n<p>This is the default output format.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-showmigrations-plan\">\n<span id=\"cmdoption-showmigrations-p\"></span><span class=\"sig-name descname\"><span class=\"pre\">--plan</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-p</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-showmigrations-plan\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Shows the migration plan Django will follow to apply migrations. Like\n<code class=\"docutils literal notranslate\"><span class=\"pre\">--list</span></code>, applied migrations are marked by an <code class=\"docutils literal notranslate\"><span class=\"pre\">[X]</span></code>. For a <code class=\"docutils literal notranslate\"><span class=\"pre\">--verbosity</span></code>\nof 2 and above, all dependencies of a migration will also be shown.</p>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">app_label</span></code>s arguments limit the output, however, dependencies of provided\napps may also be included.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-showmigrations-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-showmigrations-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database to examine. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n</section>\n<section id=\"sqlflush\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">sqlflush</span></code><a class=\"heading-anchor\" href=\"#sqlflush\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-sqlflush\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">sqlflush</span></span><a class=\"heading-anchor\" href=\"#django-admin-sqlflush\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Prints the SQL statements that would be executed for the <a class=\"reference internal\" href=\"#django-admin-flush\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">flush</span></code></a>\ncommand.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-sqlflush-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-sqlflush-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database for which to print the SQL. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n</section>\n<section id=\"sqlmigrate\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">sqlmigrate</span></code><a class=\"heading-anchor\" href=\"#sqlmigrate\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-sqlmigrate\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">sqlmigrate</span> <span class=\"pre\">app_label</span> <span class=\"pre\">migration_name</span></span><a class=\"heading-anchor\" href=\"#django-admin-sqlmigrate\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Prints the SQL for the named migration. This requires an active database\nconnection, which it will use to resolve constraint names; this means you must\ngenerate the SQL against a copy of the database you wish to later apply it on.</p>\n<p>Note that <code class=\"docutils literal notranslate\"><span class=\"pre\">sqlmigrate</span></code> doesn't colorize its output.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-sqlmigrate-backwards\">\n<span class=\"sig-name descname\"><span class=\"pre\">--backwards</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-sqlmigrate-backwards\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Generates the SQL for unapplying the migration. By default, the SQL created is\nfor running the migration in the forwards direction.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-sqlmigrate-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-sqlmigrate-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database for which to generate the SQL. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n</section>\n<section id=\"sqlsequencereset\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">sqlsequencereset</span></code><a class=\"heading-anchor\" href=\"#sqlsequencereset\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-sqlsequencereset\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">sqlsequencereset</span> <span class=\"pre\">app_label</span> <span class=\"pre\">[app_label</span> <span class=\"pre\">...]</span></span><a class=\"heading-anchor\" href=\"#django-admin-sqlsequencereset\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Prints the SQL statements for resetting sequences for the given app name(s).</p>\n<p>Sequences are indexes used by some database engines to track the next available\nnumber for automatically incremented fields.</p>\n<p>Use this command to generate SQL which will fix cases where a sequence is out\nof sync with its automatically incremented field data.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-sqlsequencereset-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-sqlsequencereset-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database for which to print the SQL. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n</section>\n<section id=\"squashmigrations\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">squashmigrations</span></code><a class=\"heading-anchor\" href=\"#squashmigrations\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-squashmigrations\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">squashmigrations</span> <span class=\"pre\">app_label</span> <span class=\"pre\">[start_migration_name]</span> <span class=\"pre\">migration_name</span></span><a class=\"heading-anchor\" href=\"#django-admin-squashmigrations\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Squashes the migrations for <code class=\"docutils literal notranslate\"><span class=\"pre\">app_label</span></code> up to and including <code class=\"docutils literal notranslate\"><span class=\"pre\">migration_name</span></code>\ndown into fewer migrations, if possible. The resulting squashed migrations\ncan live alongside the unsquashed ones safely. For more information,\nplease read <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/migrations/#migration-squashing\"><span class=\"std std-ref\">Squashing migrations</span></a>.</p>\n<p>When <code class=\"docutils literal notranslate\"><span class=\"pre\">start_migration_name</span></code> is given, Django will only include migrations\nstarting from and including this migration. This helps to mitigate the\nsquashing limitation of <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/migration-operations/#django.db.migrations.operations.RunPython\" title=\"django.db.migrations.operations.RunPython\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">RunPython</span></code></a> and\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/migration-operations/#django.db.migrations.operations.RunSQL\" title=\"django.db.migrations.operations.RunSQL\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">django.db.migrations.operations.RunSQL</span></code></a> migration operations.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-squashmigrations-no-optimize\">\n<span class=\"sig-name descname\"><span class=\"pre\">--no-optimize</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-squashmigrations-no-optimize\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Disables the optimizer when generating a squashed migration. By default, Django\nwill try to optimize the operations in your migrations to reduce the size of\nthe resulting file. Use this option if this process is failing or creating\nincorrect migrations, though please also file a Django bug report about the\nbehavior, as optimization is meant to be safe.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-squashmigrations-noinput\">\n<span id=\"cmdoption-squashmigrations-no-input\"></span><span class=\"sig-name descname\"><span class=\"pre\">--noinput</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">--no-input</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-squashmigrations-noinput\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Suppresses all user prompts.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-squashmigrations-squashed-name\">\n<span class=\"sig-name descname\"><span class=\"pre\">--squashed-name</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">SQUASHED_NAME</span></span><a class=\"heading-anchor\" href=\"#cmdoption-squashmigrations-squashed-name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Sets the name of the squashed migration. When omitted, the name is based on the\nfirst and last migration, with <code class=\"docutils literal notranslate\"><span class=\"pre\">_squashed_</span></code> in between.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-squashmigrations-no-header\">\n<span class=\"sig-name descname\"><span class=\"pre\">--no-header</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-squashmigrations-no-header\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<aside class=\"version-note version-added\" data-version=\"2.2\">\n<p class=\"version-note-title\">New in Django 2.2</p></aside>\n<p>Generate squashed migration file without Django version and timestamp header.</p>\n</section>\n<section id=\"startapp\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">startapp</span></code><a class=\"heading-anchor\" href=\"#startapp\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-startapp\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">startapp</span> <span class=\"pre\">name</span> <span class=\"pre\">[directory]</span></span><a class=\"heading-anchor\" href=\"#django-admin-startapp\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Creates a Django app directory structure for the given app name in the current\ndirectory or the given destination.</p>\n<p>By default, <a class=\"extlink-source reference external\" href=\"https://github.com/django/django/blob/stable/2.2.x/django/conf/app_template\">the new directory</a> contains a\n<code class=\"docutils literal notranslate\"><span class=\"pre\">models.py</span></code> file and other app template files. If only the app name is given,\nthe app directory will be created in the current working directory.</p>\n<p>If the optional destination is provided, Django will use that existing\ndirectory rather than creating a new one. You can use '.' to denote the current\nworking directory.</p>\n<p>例子:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">startapp</span> <span class=\"n\">myapp</span> <span class=\"o\">/</span><span class=\"n\">Users</span><span class=\"o\">/</span><span class=\"n\">jezdez</span><span class=\"o\">/</span><span class=\"n\">Code</span><span class=\"o\">/</span><span class=\"n\">myapp</span>\n</code></pre></div>\n<dl class=\"django-admin-option\" id=\"custom-app-and-project-templates\">\n<dt class=\"sig sig-object\" id=\"cmdoption-startapp-template\">\n<span class=\"sig-name descname\"><span class=\"pre\">--template</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">TEMPLATE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-startapp-template\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Provides the path to a directory with a custom app template file or a path to a\ncompressed file (<code class=\"docutils literal notranslate\"><span class=\"pre\">.tar.gz</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">.tar.bz2</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">.tgz</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">.tbz</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">.zip</span></code>)\ncontaining the app template files.</p>\n<p>For example, this would look for an app template in the given directory when\ncreating the <code class=\"docutils literal notranslate\"><span class=\"pre\">myapp</span></code> app:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">startapp</span> <span class=\"o\">--</span><span class=\"n\">template</span><span class=\"o\">=/</span><span class=\"n\">Users</span><span class=\"o\">/</span><span class=\"n\">jezdez</span><span class=\"o\">/</span><span class=\"n\">Code</span><span class=\"o\">/</span><span class=\"n\">my_app_template</span> <span class=\"n\">myapp</span>\n</code></pre></div>\n<p>Django will also accept URLs (<code class=\"docutils literal notranslate\"><span class=\"pre\">http</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">https</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">ftp</span></code>) to compressed\narchives with the app template files, downloading and extracting them on the\nfly.</p>\n<p>For example, taking advantage of GitHub's feature to expose repositories as\nzip files, you can use a URL like:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">startapp</span> <span class=\"o\">--</span><span class=\"n\">template</span><span class=\"o\">=</span><span class=\"n\">https</span><span class=\"p\">:</span><span class=\"o\">//</span><span class=\"n\">github</span><span class=\"o\">.</span><span class=\"n\">com</span><span class=\"o\">/</span><span class=\"n\">githubuser</span><span class=\"o\">/</span><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">app</span><span class=\"o\">-</span><span class=\"n\">template</span><span class=\"o\">/</span><span class=\"n\">archive</span><span class=\"o\">/</span><span class=\"n\">master</span><span class=\"o\">.</span><span class=\"n\">zip</span> <span class=\"n\">myapp</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-startapp-extension\">\n<span id=\"cmdoption-startapp-e\"></span><span class=\"sig-name descname\"><span class=\"pre\">--extension</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXTENSIONS</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-e</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXTENSIONS</span></span><a class=\"heading-anchor\" href=\"#cmdoption-startapp-extension\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies which file extensions in the app template should be rendered with the\ntemplate engine. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">py</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-startapp-name\">\n<span id=\"cmdoption-startapp-n\"></span><span class=\"sig-name descname\"><span class=\"pre\">--name</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">FILES</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-n</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">FILES</span></span><a class=\"heading-anchor\" href=\"#cmdoption-startapp-name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies which files in the app template (in addition to those matching\n<code class=\"docutils literal notranslate\"><span class=\"pre\">--extension</span></code>) should be rendered with the template engine. Defaults to an\nempty list.</p>\n<p>The <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/templates/api/#django.template.Context\" title=\"django.template.Context\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">template</span> <span class=\"pre\">context</span></code></a> used for all matching\nfiles is:</p>\n<ul class=\"simple\">\n<li><p>Any option passed to the <code class=\"docutils literal notranslate\"><span class=\"pre\">startapp</span></code> command (among the command's supported\noptions)</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">app_name</span></code> -- the app name as passed to the command</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">app_directory</span></code> -- the full path of the newly created app</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">camel_case_app_name</span></code> -- the app name in camel case format</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">docs_version</span></code> -- the version of the documentation: <code class=\"docutils literal notranslate\"><span class=\"pre\">'dev'</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">'1.x'</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">django_version</span></code> -- the version of Django, e.g. <code class=\"docutils literal notranslate\"><span class=\"pre\">'2.0.3'</span></code></p></li>\n</ul>\n<aside class=\"admonition admonition-warning\" id=\"render-warning\" role=\"note\">\n<p class=\"admonition-title\">Warning</p>\n<p>When the app template files are rendered with the Django template\nengine (by default all <code class=\"docutils literal notranslate\"><span class=\"pre\">*.py</span></code> files), Django will also replace all\nstray template variables contained. For example, if one of the Python files\ncontains a docstring explaining a particular feature related\nto template rendering, it might result in an incorrect example.</p>\n<p>To work around this problem, you can use the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/templates/builtins/#std-templatetag-templatetag\"><code class=\"xref std std-ttag docutils literal notranslate\"><span class=\"pre\">templatetag</span></code></a>\ntemplate tag to &quot;escape&quot; the various parts of the template syntax.</p>\n<p>In addition, to allow Python template files that contain Django template\nlanguage syntax while also preventing packaging systems from trying to\nbyte-compile invalid <code class=\"docutils literal notranslate\"><span class=\"pre\">*.py</span></code> files, template files ending with <code class=\"docutils literal notranslate\"><span class=\"pre\">.py-tpl</span></code>\nwill be renamed to <code class=\"docutils literal notranslate\"><span class=\"pre\">.py</span></code>.</p>\n</aside>\n</section>\n<section id=\"startproject\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">startproject</span></code><a class=\"heading-anchor\" href=\"#startproject\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-startproject\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">startproject</span> <span class=\"pre\">name</span> <span class=\"pre\">[directory]</span></span><a class=\"heading-anchor\" href=\"#django-admin-startproject\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Creates a Django project directory structure for the given project name in\nthe current directory or the given destination.</p>\n<p>By default, <a class=\"extlink-source reference external\" href=\"https://github.com/django/django/blob/stable/2.2.x/django/conf/project_template\">the new directory</a> contains\n<code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code> and a project package (containing a <code class=\"docutils literal notranslate\"><span class=\"pre\">settings.py</span></code> and other\nfiles).</p>\n<p>If only the project name is given, both the project directory and project\npackage will be named <code class=\"docutils literal notranslate\"><span class=\"pre\">&lt;projectname&gt;</span></code> and the project directory\nwill be created in the current working directory.</p>\n<p>If the optional destination is provided, Django will use that existing\ndirectory as the project directory, and create <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code> and the project\npackage within it. Use '.' to denote the current working directory.</p>\n<p>例子:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">startproject</span> <span class=\"n\">myproject</span> <span class=\"o\">/</span><span class=\"n\">Users</span><span class=\"o\">/</span><span class=\"n\">jezdez</span><span class=\"o\">/</span><span class=\"n\">Code</span><span class=\"o\">/</span><span class=\"n\">myproject_repo</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-startproject-template\">\n<span class=\"sig-name descname\"><span class=\"pre\">--template</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">TEMPLATE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-startproject-template\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies a directory, file path, or URL of a custom project template. See the\n<a class=\"reference internal\" href=\"#cmdoption-startapp-template\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">startapp</span> <span class=\"pre\">--template</span></code></a> documentation for examples and usage.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-startproject-extension\">\n<span id=\"cmdoption-startproject-e\"></span><span class=\"sig-name descname\"><span class=\"pre\">--extension</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXTENSIONS</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-e</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXTENSIONS</span></span><a class=\"heading-anchor\" href=\"#cmdoption-startproject-extension\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies which file extensions in the project template should be rendered with\nthe template engine. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">py</span></code>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-startproject-name\">\n<span id=\"cmdoption-startproject-n\"></span><span class=\"sig-name descname\"><span class=\"pre\">--name</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">FILES</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-n</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">FILES</span></span><a class=\"heading-anchor\" href=\"#cmdoption-startproject-name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies which files in the project template (in addition to those matching\n<code class=\"docutils literal notranslate\"><span class=\"pre\">--extension</span></code>) should be rendered with the template engine. Defaults to an\nempty list.</p>\n<p>The <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/templates/api/#django.template.Context\" title=\"django.template.Context\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">template</span> <span class=\"pre\">context</span></code></a> used is:</p>\n<ul class=\"simple\">\n<li><p>Any option passed to the <code class=\"docutils literal notranslate\"><span class=\"pre\">startproject</span></code> command (among the command's\nsupported options)</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">project_name</span></code> -- the project name as passed to the command</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">project_directory</span></code> -- the full path of the newly created project</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">secret_key</span></code> -- a random key for the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-SECRET_KEY\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">SECRET_KEY</span></code></a> setting</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">docs_version</span></code> -- the version of the documentation: <code class=\"docutils literal notranslate\"><span class=\"pre\">'dev'</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">'1.x'</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">django_version</span></code> -- the version of Django, e.g. <code class=\"docutils literal notranslate\"><span class=\"pre\">'2.0.3'</span></code></p></li>\n</ul>\n<p>Please also see the <a class=\"reference internal\" href=\"#render-warning\"><span class=\"std std-ref\">rendering warning</span></a> as mentioned\nfor <a class=\"reference internal\" href=\"#django-admin-startapp\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">startapp</span></code></a>.</p>\n</section>\n<section id=\"test\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">test</span></code><a class=\"heading-anchor\" href=\"#test\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-test\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">test</span> <span class=\"pre\">[test_label</span> <span class=\"pre\">[test_label</span> <span class=\"pre\">...]]</span></span><a class=\"heading-anchor\" href=\"#django-admin-test\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Runs tests for all installed apps. See <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/testing/\"><span class=\"doc\">Django 中的测试</span></a> for more\ninformation.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-test-failfast\">\n<span class=\"sig-name descname\"><span class=\"pre\">--failfast</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-test-failfast\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Stops running tests and reports the failure immediately after a test fails.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-test-testrunner\">\n<span class=\"sig-name descname\"><span class=\"pre\">--testrunner</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">TESTRUNNER</span></span><a class=\"heading-anchor\" href=\"#cmdoption-test-testrunner\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Controls the test runner class that is used to execute tests. This value\noverrides the value provided by the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-TEST_RUNNER\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">TEST_RUNNER</span></code></a> setting.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-test-noinput\">\n<span id=\"cmdoption-test-no-input\"></span><span class=\"sig-name descname\"><span class=\"pre\">--noinput</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">--no-input</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-test-noinput\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Suppresses all user prompts. A typical prompt is a warning about deleting an\nexisting test database.</p>\n<section id=\"test-runner-options\">\n<h4>Test runner options<a class=\"heading-anchor\" href=\"#test-runner-options\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">test</span></code> command receives options on behalf of the specified\n<a class=\"reference internal\" href=\"#cmdoption-test-testrunner\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--testrunner</span></code></a>. These are the options of the default test runner:\n<a class=\"reference internal\" href=\"/zh-hans/2.2/topics/testing/advanced/#django.test.runner.DiscoverRunner\" title=\"django.test.runner.DiscoverRunner\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">DiscoverRunner</span></code></a>.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-test-keepdb\">\n<span id=\"cmdoption-test-k\"></span><span class=\"sig-name descname\"><span class=\"pre\">--keepdb</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-k</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-test-keepdb\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Preserves the test database between test runs. This has the advantage of\nskipping both the create and destroy actions which can greatly decrease the\ntime to run tests, especially those in a large test suite. If the test database\ndoes not exist, it will be created on the first run and then preserved for each\nsubsequent run. Any unapplied migrations will also be applied to the test\ndatabase before running the test suite.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-test-reverse\">\n<span id=\"cmdoption-test-r\"></span><span class=\"sig-name descname\"><span class=\"pre\">--reverse</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-r</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-test-reverse\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Sorts test cases in the opposite execution order. This may help in debugging\nthe side effects of tests that aren't properly isolated. <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/testing/overview/#order-of-tests\"><span class=\"std std-ref\">Grouping by test\nclass</span></a> is preserved when using this option.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-test-debug-mode\">\n<span class=\"sig-name descname\"><span class=\"pre\">--debug-mode</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-test-debug-mode\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Sets the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> setting to <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code> prior to running tests. This may\nhelp troubleshoot test failures.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-test-debug-sql\">\n<span id=\"cmdoption-test-d\"></span><span class=\"sig-name descname\"><span class=\"pre\">--debug-sql</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-d</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-test-debug-sql\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Enables <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/logging/#django-db-logger\"><span class=\"std std-ref\">SQL logging</span></a> for failing tests. If\n<code class=\"docutils literal notranslate\"><span class=\"pre\">--verbosity</span></code> is <code class=\"docutils literal notranslate\"><span class=\"pre\">2</span></code>, then queries in passing tests are also output.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-test-parallel\">\n<span class=\"sig-name descname\"><span class=\"pre\">--parallel</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">[N]</span></span><a class=\"heading-anchor\" href=\"#cmdoption-test-parallel\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Runs tests in separate parallel processes. Since modern processors have\nmultiple cores, this allows running tests significantly faster.</p>\n<p>By default <code class=\"docutils literal notranslate\"><span class=\"pre\">--parallel</span></code> runs one process per core according to\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/multiprocessing.html#multiprocessing.cpu_count\" title=\"(in Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">multiprocessing.cpu_count()</span></code></a>. You can adjust the number of processes\neither by providing it as the option's value, e.g. <code class=\"docutils literal notranslate\"><span class=\"pre\">--parallel=4</span></code>, or by\nsetting the <code class=\"docutils literal notranslate\"><span class=\"pre\">DJANGO_TEST_PROCESSES</span></code> environment variable.</p>\n<p>Django distributes test cases — <a class=\"reference external\" href=\"https://docs.python.org/3/library/unittest.html#unittest.TestCase\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">unittest.TestCase</span></code></a> subclasses — to\nsubprocesses. If there are fewer test cases than configured processes, Django\nwill reduce the number of processes accordingly.</p>\n<p>Each process gets its own database. You must ensure that different test cases\ndon't access the same resources. For instance, test cases that touch the\nfilesystem should create a temporary directory for their own use.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>If you have test classes that cannot be run in parallel, you can use\n<code class=\"docutils literal notranslate\"><span class=\"pre\">SerializeMixin</span></code> to run them sequentially. See <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/testing/advanced/#topics-testing-enforce-run-sequentially\"><span class=\"std std-ref\">Enforce running test\nclasses sequentially</span></a>.</p>\n</aside>\n<p>This option requires the third-party <code class=\"docutils literal notranslate\"><span class=\"pre\">tblib</span></code> package to display tracebacks\ncorrectly:</p>\n<div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>pip<span class=\"w\"> </span>install<span class=\"w\"> </span>tblib\n</code></pre></div>\n<p>This feature isn't available on Windows. It doesn't work with the Oracle\ndatabase backend either.</p>\n<p>If you want to use <a class=\"reference external\" href=\"https://docs.python.org/3/library/pdb.html#module-pdb\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">pdb</span></code></a> while debugging tests, you must disable parallel\nexecution (<code class=\"docutils literal notranslate\"><span class=\"pre\">--parallel=1</span></code>). You'll see something like <code class=\"docutils literal notranslate\"><span class=\"pre\">bdb.BdbQuit</span></code> if you\ndon't.</p>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Warning</p>\n<p>When test parallelization is enabled and a test fails, Django may be\nunable to display the exception traceback. This can make debugging\ndifficult. If you encounter this problem, run the affected test without\nparallelization to see the traceback of the failure.</p>\n<p>This is a known limitation. It arises from the need to serialize objects\nin order to exchange them between processes. See\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/pickle.html#pickle-picklable\" title=\"(in Python v3.14)\"><span>What can be pickled and unpickled?</span></a> for details.</p>\n</aside>\n<dl class=\"std option\">\n<dt class=\"sig sig-object std\" id=\"cmdoption-test-tag\">\n<span class=\"sig-name descname\"><span class=\"pre\">--tag</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">TAGS</span></span><a class=\"heading-anchor\" href=\"#cmdoption-test-tag\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Runs only tests <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/testing/tools/#topics-tagging-tests\"><span class=\"std std-ref\">marked with the specified tags</span></a>.\nMay be specified multiple times and combined with <a class=\"reference internal\" href=\"#cmdoption-test-exclude-tag\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">test</span> <span class=\"pre\">--exclude-tag</span></code></a>.</p>\n<dl class=\"std option\">\n<dt class=\"sig sig-object std\" id=\"cmdoption-test-exclude-tag\">\n<span class=\"sig-name descname\"><span class=\"pre\">--exclude-tag</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EXCLUDE_TAGS</span></span><a class=\"heading-anchor\" href=\"#cmdoption-test-exclude-tag\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Excludes tests <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/testing/tools/#topics-tagging-tests\"><span class=\"std std-ref\">marked with the specified tags</span></a>.\nMay be specified multiple times and combined with <a class=\"reference internal\" href=\"#cmdoption-test-tag\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">test</span> <span class=\"pre\">--tag</span></code></a>.</p>\n</section>\n</section>\n<section id=\"testserver\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">testserver</span></code><a class=\"heading-anchor\" href=\"#testserver\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-testserver\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">testserver</span> <span class=\"pre\">[fixture</span> <span class=\"pre\">[fixture</span> <span class=\"pre\">...]]</span></span><a class=\"heading-anchor\" href=\"#django-admin-testserver\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Runs a Django development server (as in <a class=\"reference internal\" href=\"#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">runserver</span></code></a>) using data from\nthe given fixture(s).</p>\n<p>For example, this command:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">testserver</span> <span class=\"n\">mydata</span><span class=\"o\">.</span><span class=\"n\">json</span>\n</code></pre></div>\n<p>...would perform the following steps:</p>\n<ol class=\"arabic simple\">\n<li><p>Create a test database, as described in <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/testing/overview/#the-test-database\"><span class=\"std std-ref\">The test database</span></a>.</p></li>\n<li><p>Populate the test database with fixture data from the given fixtures.\n(For more on fixtures, see the documentation for <a class=\"reference internal\" href=\"#django-admin-loaddata\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">loaddata</span></code></a> above.)</p></li>\n<li><p>Runs the Django development server (as in <a class=\"reference internal\" href=\"#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">runserver</span></code></a>), pointed at\nthis newly created test database instead of your production database.</p></li>\n</ol>\n<p>This is useful in a number of ways:</p>\n<ul class=\"simple\">\n<li><p>When you're writing <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/testing/overview/\"><span class=\"doc\">unit tests</span></a> of how your views\nact with certain fixture data, you can use <code class=\"docutils literal notranslate\"><span class=\"pre\">testserver</span></code> to interact with\nthe views in a Web browser, manually.</p></li>\n<li><p>Let's say you're developing your Django application and have a &quot;pristine&quot;\ncopy of a database that you'd like to interact with. You can dump your\ndatabase to a fixture (using the <a class=\"reference internal\" href=\"#django-admin-dumpdata\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">dumpdata</span></code></a> command, explained\nabove), then use <code class=\"docutils literal notranslate\"><span class=\"pre\">testserver</span></code> to run your Web application with that data.\nWith this arrangement, you have the flexibility of messing up your data\nin any way, knowing that whatever data changes you're making are only\nbeing made to a test database.</p></li>\n</ul>\n<p>Note that this server does <em>not</em> automatically detect changes to your Python\nsource code (as <a class=\"reference internal\" href=\"#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">runserver</span></code></a> does). It does, however, detect changes to\ntemplates.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-testserver-addrport\">\n<span class=\"sig-name descname\"><span class=\"pre\">--addrport</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">ADDRPORT</span></span><a class=\"heading-anchor\" href=\"#cmdoption-testserver-addrport\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies a different port, or IP address and port, from the default of\n<code class=\"docutils literal notranslate\"><span class=\"pre\">127.0.0.1:8000</span></code>. This value follows exactly the same format and serves\nexactly the same function as the argument to the <a class=\"reference internal\" href=\"#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">runserver</span></code></a> command.</p>\n<p>Examples:</p>\n<p>To run the test server on port 7000 with <code class=\"docutils literal notranslate\"><span class=\"pre\">fixture1</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">fixture2</span></code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">testserver</span> <span class=\"o\">--</span><span class=\"n\">addrport</span> <span class=\"mi\">7000</span> <span class=\"n\">fixture1</span> <span class=\"n\">fixture2</span>\n<span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">testserver</span> <span class=\"n\">fixture1</span> <span class=\"n\">fixture2</span> <span class=\"o\">--</span><span class=\"n\">addrport</span> <span class=\"mi\">7000</span>\n</code></pre></div>\n<p>(The above statements are equivalent. We include both of them to demonstrate\nthat it doesn't matter whether the options come before or after the fixture\narguments.)</p>\n<p>To run on 1.2.3.4:7000 with a <code class=\"docutils literal notranslate\"><span class=\"pre\">test</span></code> fixture:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">testserver</span> <span class=\"o\">--</span><span class=\"n\">addrport</span> <span class=\"mf\">1.2.3.4</span><span class=\"p\">:</span><span class=\"mi\">7000</span> <span class=\"n\">test</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-testserver-noinput\">\n<span id=\"cmdoption-testserver-no-input\"></span><span class=\"sig-name descname\"><span class=\"pre\">--noinput</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">--no-input</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-testserver-noinput\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Suppresses all user prompts. A typical prompt is a warning about deleting an\nexisting test database.</p>\n</section>\n</section>\n<section id=\"commands-provided-by-applications\">\n<h2>Commands provided by applications<a class=\"heading-anchor\" href=\"#commands-provided-by-applications\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Some commands are only available when the <code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib</span></code> application that\n<a class=\"reference internal\" href=\"/zh-hans/2.2/howto/custom-management-commands/\"><span class=\"doc\">implements</span></a> them has been\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">enabled</span></code></a>. This section describes them grouped by\ntheir application.</p>\n<section id=\"django-contrib-auth\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.auth</span></code><a class=\"heading-anchor\" href=\"#django-contrib-auth\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"changepassword\">\n<h4><code class=\"docutils literal notranslate\"><span class=\"pre\">changepassword</span></code><a class=\"heading-anchor\" href=\"#changepassword\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-changepassword\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">changepassword</span> <span class=\"pre\">[&lt;username&gt;]</span></span><a class=\"heading-anchor\" href=\"#django-admin-changepassword\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>This command is only available if Django's <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/auth/\"><span class=\"doc\">authentication system</span></a> (<code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.auth</span></code>) is installed.</p>\n<p>Allows changing a user's password. It prompts you to enter a new password twice\nfor the given user. If the entries are identical, this immediately becomes the\nnew password. If you do not supply a user, the command will attempt to change\nthe password whose username matches the current user.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-changepassword-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-changepassword-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database to query for the user. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">changepassword</span> <span class=\"n\">ringo</span>\n</code></pre></div>\n</section>\n<section id=\"createsuperuser\">\n<h4><code class=\"docutils literal notranslate\"><span class=\"pre\">createsuperuser</span></code><a class=\"heading-anchor\" href=\"#createsuperuser\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-createsuperuser\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">createsuperuser</span></span><a class=\"heading-anchor\" href=\"#django-admin-createsuperuser\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>This command is only available if Django's <a class=\"reference internal\" href=\"/zh-hans/2.2/topics/auth/\"><span class=\"doc\">authentication system</span></a> (<code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.auth</span></code>) is installed.</p>\n<p>Creates a superuser account (a user who has all permissions). This is\nuseful if you need to create an initial superuser account or if you need to\nprogrammatically generate superuser accounts for your site(s).</p>\n<p>When run interactively, this command will prompt for a password for\nthe new superuser account. When run non-interactively, no password\nwill be set, and the superuser account will not be able to log in until\na password has been manually set for it.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-createsuperuser-noinput\">\n<span id=\"cmdoption-createsuperuser-no-input\"></span><span class=\"sig-name descname\"><span class=\"pre\">--noinput</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">--no-input</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-createsuperuser-noinput\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Suppresses all user prompts. If a suppressed prompt cannot be resolved\nautomatically, the command will exit with error code 1.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-createsuperuser-username\">\n<span class=\"sig-name descname\"><span class=\"pre\">--username</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">USERNAME</span></span><a class=\"heading-anchor\" href=\"#cmdoption-createsuperuser-username\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-createsuperuser-email\">\n<span class=\"sig-name descname\"><span class=\"pre\">--email</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">EMAIL</span></span><a class=\"heading-anchor\" href=\"#cmdoption-createsuperuser-email\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The username and email address for the new account can be supplied by\nusing the <code class=\"docutils literal notranslate\"><span class=\"pre\">--username</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">--email</span></code> arguments on the command\nline. If either of those is not supplied, <code class=\"docutils literal notranslate\"><span class=\"pre\">createsuperuser</span></code> will prompt for\nit when running interactively.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-createsuperuser-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-createsuperuser-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database into which the superuser object will be saved.</p>\n<p>You can subclass the management command and override <code class=\"docutils literal notranslate\"><span class=\"pre\">get_input_data()</span></code> if you\nwant to customize data input and validation. Consult the source code for\ndetails on the existing implementation and the method's parameters. For example,\nit could be useful if you have a <code class=\"docutils literal notranslate\"><span class=\"pre\">ForeignKey</span></code> in\n<a class=\"reference internal\" href=\"/zh-hans/2.2/topics/auth/customizing/#django.contrib.auth.models.CustomUser.REQUIRED_FIELDS\" title=\"django.contrib.auth.models.CustomUser.REQUIRED_FIELDS\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">REQUIRED_FIELDS</span></code></a> and want to\nallow creating an instance instead of entering the primary key of an existing\ninstance.</p>\n</section>\n</section>\n<section id=\"django-contrib-contenttypes\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.contenttypes</span></code><a class=\"heading-anchor\" href=\"#django-contrib-contenttypes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"remove-stale-contenttypes\">\n<h4><code class=\"docutils literal notranslate\"><span class=\"pre\">remove_stale_contenttypes</span></code><a class=\"heading-anchor\" href=\"#remove-stale-contenttypes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-remove_stale_contenttypes\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">remove_stale_contenttypes</span></span><a class=\"heading-anchor\" href=\"#django-admin-remove_stale_contenttypes\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>This command is only available if Django's <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/contenttypes/\"><span class=\"doc\">contenttypes app</span></a> (<a class=\"reference internal\" href=\"/zh-hans/2.2/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\"><span class=\"pre\">django.contrib.contenttypes</span></code></a>) is installed.</p>\n<p>Deletes stale content types (from deleted models) in your database. Any objects\nthat depend on the deleted content types will also be deleted. A list of\ndeleted objects will be displayed before you confirm it's okay to proceed with\nthe deletion.</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-remove_stale_contenttypes-database\">\n<span class=\"sig-name descname\"><span class=\"pre\">--database</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">DATABASE</span></span><a class=\"heading-anchor\" href=\"#cmdoption-remove_stale_contenttypes-database\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the database to use. Defaults to <code class=\"docutils literal notranslate\"><span class=\"pre\">default</span></code>.</p>\n</section>\n</section>\n<section id=\"django-contrib-gis\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.gis</span></code><a class=\"heading-anchor\" href=\"#django-contrib-gis\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"ogrinspect\">\n<h4><code class=\"docutils literal notranslate\"><span class=\"pre\">ogrinspect</span></code><a class=\"heading-anchor\" href=\"#ogrinspect\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>This command is only available if <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/gis/\"><span class=\"doc\">GeoDjango</span></a>\n(<code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.gis</span></code>) is installed.</p>\n<p>Please refer to its <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/gis/commands/#django-admin-ogrinspect\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">description</span></code></a> in the GeoDjango\ndocumentation.</p>\n</section>\n</section>\n<section id=\"django-contrib-sessions\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.sessions</span></code><a class=\"heading-anchor\" href=\"#django-contrib-sessions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"clearsessions\">\n<h4><code class=\"docutils literal notranslate\"><span class=\"pre\">clearsessions</span></code><a class=\"heading-anchor\" href=\"#clearsessions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-clearsessions\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">clearsessions</span></span><a class=\"heading-anchor\" href=\"#django-admin-clearsessions\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Can be run as a cron job or directly to clean out expired sessions.</p>\n</section>\n</section>\n<section id=\"django-contrib-sitemaps\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.sitemaps</span></code><a class=\"heading-anchor\" href=\"#django-contrib-sitemaps\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"ping-google\">\n<h4><code class=\"docutils literal notranslate\"><span class=\"pre\">ping_google</span></code><a class=\"heading-anchor\" href=\"#ping-google\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>This command is only available if the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/sitemaps/\"><span class=\"doc\">Sitemaps framework</span></a> (<code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.sitemaps</span></code>) is installed.</p>\n<p>Please refer to its <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/sitemaps/#django-admin-ping_google\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">description</span></code></a> in the Sitemaps\ndocumentation.</p>\n</section>\n</section>\n<section id=\"django-contrib-staticfiles\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.staticfiles</span></code><a class=\"heading-anchor\" href=\"#django-contrib-staticfiles\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"collectstatic\">\n<h4><code class=\"docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code><a class=\"heading-anchor\" href=\"#collectstatic\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>This command is only available if the <a class=\"reference internal\" href=\"/zh-hans/2.2/howto/static-files/\"><span class=\"doc\">static files application</span></a> (<code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.staticfiles</span></code>) is installed.</p>\n<p>Please refer to its <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/staticfiles/#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">description</span></code></a> in the\n<a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> documentation.</p>\n</section>\n<section id=\"findstatic\">\n<h4><code class=\"docutils literal notranslate\"><span class=\"pre\">findstatic</span></code><a class=\"heading-anchor\" href=\"#findstatic\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>This command is only available if the <a class=\"reference internal\" href=\"/zh-hans/2.2/howto/static-files/\"><span class=\"doc\">static files application</span></a> (<code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.staticfiles</span></code>) is installed.</p>\n<p>Please refer to its <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/staticfiles/#django-admin-findstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">description</span></code></a> in the <a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> documentation.</p>\n</section>\n</section>\n</section>\n<section id=\"default-options\">\n<h2>Default options<a class=\"heading-anchor\" href=\"#default-options\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Although some commands may allow their own custom options, every command\nallows for the following options:</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-pythonpath\">\n<span class=\"sig-name descname\"><span class=\"pre\">--pythonpath</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">PYTHONPATH</span></span><a class=\"heading-anchor\" href=\"#cmdoption-pythonpath\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Adds the given filesystem path to the Python <a class=\"reference external\" href=\"https://www.diveinto.org/python3/your-first-python-program.html#importsearchpath\">import search path</a>. If this\nisn't provided, <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> will use the <code class=\"docutils literal notranslate\"><span class=\"pre\">PYTHONPATH</span></code> environment\nvariable.</p>\n<p>This option is unnecessary in <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code>, because it takes care of setting\nthe Python path for you.</p>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">migrate</span> <span class=\"o\">--</span><span class=\"n\">pythonpath</span><span class=\"o\">=</span><span class=\"s1\">&#39;/home/djangoprojects/myproject&#39;</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-settings\">\n<span class=\"sig-name descname\"><span class=\"pre\">--settings</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">SETTINGS</span></span><a class=\"heading-anchor\" href=\"#cmdoption-settings\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the settings module to use. The settings module should be in Python\npackage syntax, e.g. <code class=\"docutils literal notranslate\"><span class=\"pre\">mysite.settings</span></code>. If this isn't provided,\n<code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> will use the <code class=\"docutils literal notranslate\"><span class=\"pre\">DJANGO_SETTINGS_MODULE</span></code> environment variable.</p>\n<p>This option is unnecessary in <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code>, because it uses\n<code class=\"docutils literal notranslate\"><span class=\"pre\">settings.py</span></code> from the current project by default.</p>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">migrate</span> <span class=\"o\">--</span><span class=\"n\">settings</span><span class=\"o\">=</span><span class=\"n\">mysite</span><span class=\"o\">.</span><span class=\"n\">settings</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-traceback\">\n<span class=\"sig-name descname\"><span class=\"pre\">--traceback</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-traceback\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Displays a full stack trace when a <a class=\"reference internal\" href=\"/zh-hans/2.2/howto/custom-management-commands/#django.core.management.CommandError\" title=\"django.core.management.CommandError\"><code class=\"xref py py-exc docutils literal notranslate\"><span class=\"pre\">CommandError</span></code></a>\nis raised. By default, <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> will show a simple error message when a\n<code class=\"docutils literal notranslate\"><span class=\"pre\">CommandError</span></code> occurs and a full stack trace for any other exception.</p>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">migrate</span> <span class=\"o\">--</span><span class=\"n\">traceback</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-verbosity\">\n<span id=\"cmdoption-v\"></span><span class=\"sig-name descname\"><span class=\"pre\">--verbosity</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">{0,1,2,3}</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-v</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">{0,1,2,3}</span></span><a class=\"heading-anchor\" href=\"#cmdoption-verbosity\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Specifies the amount of notification and debug information that a command\nshould print to the console.</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">0</span></code> means no output.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">1</span></code> means normal output (default).</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">2</span></code> means verbose output.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">3</span></code> means <em>very</em> verbose output.</p></li>\n</ul>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">migrate</span> <span class=\"o\">--</span><span class=\"n\">verbosity</span> <span class=\"mi\">2</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-no-color\">\n<span class=\"sig-name descname\"><span class=\"pre\">--no-color</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-no-color\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Disables colorized command output.  Some commands format their output to be\ncolorized. For example, errors will be printed to the console in red and SQL\nstatements will be syntax highlighted.</p>\n<p>用法示例：</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">django</span><span class=\"o\">-</span><span class=\"n\">admin</span> <span class=\"n\">runserver</span> <span class=\"o\">--</span><span class=\"n\">no</span><span class=\"o\">-</span><span class=\"n\">color</span>\n</code></pre></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-force-color\">\n<span class=\"sig-name descname\"><span class=\"pre\">--force-color</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-force-color\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<aside class=\"version-note version-added\" data-version=\"2.2\">\n<p class=\"version-note-title\">New in Django 2.2</p></aside>\n<p>Forces colorization of the command output if it would otherwise be disabled\nas discussed in <a class=\"reference internal\" href=\"#syntax-coloring\"><span class=\"std std-ref\">Syntax coloring</span></a>. For example, you may want to pipe\ncolored output to another command.</p>\n</section>\n<section id=\"extra-niceties\">\n<h2>Extra niceties<a class=\"heading-anchor\" href=\"#extra-niceties\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"syntax-coloring\">\n<span id=\"id1\"></span><h3>Syntax coloring<a class=\"heading-anchor\" href=\"#syntax-coloring\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> / <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code> commands will use pretty\ncolor-coded output if your terminal supports ANSI-colored output. It\nwon't use the color codes if you're piping the command's output to\nanother program unless the <a class=\"reference internal\" href=\"#cmdoption-force-color\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">--force-color</span></code></a> option is used.</p>\n<p>Under Windows, the native console doesn't support ANSI escape sequences so by\ndefault there is no color output. But you can install the <a class=\"reference external\" href=\"http://adoxa.altervista.org/ansicon/\">ANSICON</a>\nthird-party tool, the Django commands will detect its presence and will make\nuse of its services to color output just like on Unix-based platforms.</p>\n<p>The colors used for syntax highlighting can be customized. Django\nships with three color palettes:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">dark</span></code>, suited to terminals that show white text on a black\nbackground. This is the default palette.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">light</span></code>, suited to terminals that show black text on a white\nbackground.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">nocolor</span></code>, which disables syntax highlighting.</p></li>\n</ul>\n<p>You select a palette by setting a <code class=\"docutils literal notranslate\"><span class=\"pre\">DJANGO_COLORS</span></code> environment\nvariable to specify the palette you want to use. For example, to\nspecify the <code class=\"docutils literal notranslate\"><span class=\"pre\">light</span></code> palette under a Unix or OS/X BASH shell, you\nwould run the following at a command prompt:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">export</span> <span class=\"n\">DJANGO_COLORS</span><span class=\"o\">=</span><span class=\"s2\">&quot;light&quot;</span>\n</code></pre></div>\n<p>You can also customize the colors that are used. Django specifies a\nnumber of roles in which color is used:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">error</span></code> - A major error.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">notice</span></code> - A minor error.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">success</span></code> - A success.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">warning</span></code> - A warning.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">sql_field</span></code> - The name of a model field in SQL.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">sql_coltype</span></code> - The type of a model field in SQL.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">sql_keyword</span></code> - An SQL keyword.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">sql_table</span></code> - The name of a model in SQL.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">http_info</span></code> - A 1XX HTTP Informational server response.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">http_success</span></code> - A 2XX HTTP Success server response.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">http_not_modified</span></code> - A 304 HTTP Not Modified server response.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">http_redirect</span></code> - A 3XX HTTP Redirect server response other than 304.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">http_not_found</span></code> - A 404 HTTP Not Found server response.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">http_bad_request</span></code> - A 4XX HTTP Bad Request server response other than 404.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">http_server_error</span></code> - A 5XX HTTP Server Error response.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">migrate_heading</span></code> - A heading in a migrations management command.</p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">migrate_label</span></code> - A migration name.</p></li>\n</ul>\n<p>Each of these roles can be assigned a specific foreground and\nbackground color, from the following list:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">black</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">red</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">green</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">yellow</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">blue</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">magenta</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">cyan</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">white</span></code></p></li>\n</ul>\n<p>Each of these colors can then be modified by using the following\ndisplay options:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">bold</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">underscore</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">blink</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">reverse</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">conceal</span></code></p></li>\n</ul>\n<p>A color specification follows one of the following patterns:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">role=fg</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">role=fg/bg</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">role=fg,option,option</span></code></p></li>\n<li><p><code class=\"docutils literal notranslate\"><span class=\"pre\">role=fg/bg,option,option</span></code></p></li>\n</ul>\n<p>where <code class=\"docutils literal notranslate\"><span class=\"pre\">role</span></code> is the name of a valid color role, <code class=\"docutils literal notranslate\"><span class=\"pre\">fg</span></code> is the\nforeground color, <code class=\"docutils literal notranslate\"><span class=\"pre\">bg</span></code> is the background color and each <code class=\"docutils literal notranslate\"><span class=\"pre\">option</span></code>\nis one of the color modifying options. Multiple color specifications\nare then separated by a semicolon. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">export</span> <span class=\"n\">DJANGO_COLORS</span><span class=\"o\">=</span><span class=\"s2\">&quot;error=yellow/blue,blink;notice=magenta&quot;</span>\n</code></pre></div>\n<p>would specify that errors be displayed using blinking yellow on blue,\nand notices displayed using magenta. All other color roles would be\nleft uncolored.</p>\n<p>Colors can also be specified by extending a base palette. If you put\na palette name in a color specification, all the colors implied by that\npalette will be loaded. So:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">export</span> <span class=\"n\">DJANGO_COLORS</span><span class=\"o\">=</span><span class=\"s2\">&quot;light;error=yellow/blue,blink;notice=magenta&quot;</span>\n</code></pre></div>\n<p>would specify the use of all the colors in the light color palette,\n<em>except</em> for the colors for errors and notices which would be\noverridden as specified.</p>\n</section>\n<section id=\"bash-completion\">\n<h3>Bash completion<a class=\"heading-anchor\" href=\"#bash-completion\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>If you use the Bash shell, consider installing the Django bash completion\nscript, which lives in <code class=\"docutils literal notranslate\"><span class=\"pre\">extras/django_bash_completion</span></code> in the Django source\ndistribution. It enables tab-completion of <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> and\n<code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code> commands, so you can, for instance...</p>\n<ul class=\"simple\">\n<li><p>Type <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code>.</p></li>\n<li><p>Press [TAB] to see all available options.</p></li>\n<li><p>Type <code class=\"docutils literal notranslate\"><span class=\"pre\">sql</span></code>, then [TAB], to see all available options whose names start\nwith <code class=\"docutils literal notranslate\"><span class=\"pre\">sql</span></code>.</p></li>\n</ul>\n<p>See <a class=\"reference internal\" href=\"/zh-hans/2.2/howto/custom-management-commands/\"><span class=\"doc\">编写自定义 django-admin 命令</span></a> for how to add customized actions.</p>\n</section>\n</section>\n</section>\n<section id=\"running-management-commands-from-your-code\">\n<h1>Running management commands from your code<a class=\"heading-anchor\" href=\"#running-management-commands-from-your-code\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.core.management.call_command\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">django.core.management.</span></span><span class=\"sig-name descname\"><span class=\"pre\">call_command</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em>, <em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">*</span></span><span class=\"n\"><span class=\"pre\">args</span></span></em>, <em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">**</span></span><span class=\"n\"><span class=\"pre\">options</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.management.call_command\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>To call a management command from code use <code class=\"docutils literal notranslate\"><span class=\"pre\">call_command</span></code>.</p>\n<dl class=\"simple\">\n<dt><code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code></dt><dd><p>the name of the command to call or a command object. Passing the name is\npreferred unless the object is required for testing.</p>\n</dd>\n<dt><code class=\"docutils literal notranslate\"><span class=\"pre\">*args</span></code></dt><dd><p>a list of arguments accepted by the command. Arguments are passed to the\nargument parser, so you can use the same style as you would on the command\nline. For example, <code class=\"docutils literal notranslate\"><span class=\"pre\">call_command('flush',</span> <span class=\"pre\">'--verbosity=0')</span></code>.</p>\n</dd>\n<dt><code class=\"docutils literal notranslate\"><span class=\"pre\">**options</span></code></dt><dd><p>named options accepted on the command-line. Options are passed to the command\nwithout triggering the argument parser, which means you'll need to pass the\ncorrect type. For example, <code class=\"docutils literal notranslate\"><span class=\"pre\">call_command('flush',</span> <span class=\"pre\">verbosity=0)</span></code> (zero must\nbe an integer rather than a string).</p>\n</dd>\n</dl>\n<p>举例:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.core</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">management</span>\n<span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.core.management.commands</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">loaddata</span>\n\n<span class=\"n\">management</span><span class=\"o\">.</span><span class=\"n\">call_command</span><span class=\"p\">(</span><span class=\"s1\">&#39;flush&#39;</span><span class=\"p\">,</span> <span class=\"n\">verbosity</span><span class=\"o\">=</span><span class=\"mi\">0</span><span class=\"p\">,</span> <span class=\"n\">interactive</span><span class=\"o\">=</span><span class=\"kc\">False</span><span class=\"p\">)</span>\n<span class=\"n\">management</span><span class=\"o\">.</span><span class=\"n\">call_command</span><span class=\"p\">(</span><span class=\"s1\">&#39;loaddata&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;test_data&#39;</span><span class=\"p\">,</span> <span class=\"n\">verbosity</span><span class=\"o\">=</span><span class=\"mi\">0</span><span class=\"p\">)</span>\n<span class=\"n\">management</span><span class=\"o\">.</span><span class=\"n\">call_command</span><span class=\"p\">(</span><span class=\"n\">loaddata</span><span class=\"o\">.</span><span class=\"n\">Command</span><span class=\"p\">(),</span> <span class=\"s1\">&#39;test_data&#39;</span><span class=\"p\">,</span> <span class=\"n\">verbosity</span><span class=\"o\">=</span><span class=\"mi\">0</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>Note that command options that take no arguments are passed as keywords\nwith <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code>, as you can see with the <code class=\"docutils literal notranslate\"><span class=\"pre\">interactive</span></code> option above.</p>\n<p>Named arguments can be passed by using either one of the following syntaxes:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"c1\"># Similar to the command line</span>\n<span class=\"n\">management</span><span class=\"o\">.</span><span class=\"n\">call_command</span><span class=\"p\">(</span><span class=\"s1\">&#39;dumpdata&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;--natural-foreign&#39;</span><span class=\"p\">)</span>\n\n<span class=\"c1\"># Named argument similar to the command line minus the initial dashes and</span>\n<span class=\"c1\"># with internal dashes replaced by underscores</span>\n<span class=\"n\">management</span><span class=\"o\">.</span><span class=\"n\">call_command</span><span class=\"p\">(</span><span class=\"s1\">&#39;dumpdata&#39;</span><span class=\"p\">,</span> <span class=\"n\">natural_foreign</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">)</span>\n\n<span class=\"c1\"># `use_natural_foreign_keys` is the option destination variable</span>\n<span class=\"n\">management</span><span class=\"o\">.</span><span class=\"n\">call_command</span><span class=\"p\">(</span><span class=\"s1\">&#39;dumpdata&#39;</span><span class=\"p\">,</span> <span class=\"n\">use_natural_foreign_keys</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>Some command options have different names when using <code class=\"docutils literal notranslate\"><span class=\"pre\">call_command()</span></code> instead\nof <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code>. For example, <code class=\"docutils literal notranslate\"><span class=\"pre\">django-admin</span>\n<span class=\"pre\">createsuperuser</span> <span class=\"pre\">--no-input</span></code> translates to <code class=\"docutils literal notranslate\"><span class=\"pre\">call_command('createsuperuser',</span>\n<span class=\"pre\">interactive=False)</span></code>. To find what keyword argument name to use for\n<code class=\"docutils literal notranslate\"><span class=\"pre\">call_command()</span></code>, check the command's source code for the <code class=\"docutils literal notranslate\"><span class=\"pre\">dest</span></code> argument\npassed to <code class=\"docutils literal notranslate\"><span class=\"pre\">parser.add_argument()</span></code>.</p>\n<p>Command options which take multiple options are passed a list:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">management</span><span class=\"o\">.</span><span class=\"n\">call_command</span><span class=\"p\">(</span><span class=\"s1\">&#39;dumpdata&#39;</span><span class=\"p\">,</span> <span class=\"n\">exclude</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"s1\">&#39;contenttypes&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;auth&#39;</span><span class=\"p\">])</span>\n</code></pre></div>\n<p>The return value of the <code class=\"docutils literal notranslate\"><span class=\"pre\">call_command()</span></code> function is the same as the return\nvalue of the <code class=\"docutils literal notranslate\"><span class=\"pre\">handle()</span></code> method of the command.</p>\n<section id=\"output-redirection\">\n<h2>Output redirection<a class=\"heading-anchor\" href=\"#output-redirection\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Note that you can redirect standard output and error streams as all commands\nsupport the <code class=\"docutils literal notranslate\"><span class=\"pre\">stdout</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">stderr</span></code> options. For example, you could write:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">with</span> <span class=\"nb\">open</span><span class=\"p\">(</span><span class=\"s1\">&#39;/path/to/command_output&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;w&#39;</span><span class=\"p\">)</span> <span class=\"k\">as</span> <span class=\"n\">f</span><span class=\"p\">:</span>\n    <span class=\"n\">management</span><span class=\"o\">.</span><span class=\"n\">call_command</span><span class=\"p\">(</span><span class=\"s1\">&#39;dumpdata&#39;</span><span class=\"p\">,</span> <span class=\"n\">stdout</span><span class=\"o\">=</span><span class=\"n\">f</span><span class=\"p\">)</span>\n</code></pre></div>\n</section>\n</section>\n","rootId":"","toc":[{"title":"django-admin and manage.py","anchor":"","children":[{"title":"用法","anchor":"usage","children":[{"title":"Getting runtime help","anchor":"getting-runtime-help","children":[]},{"title":"App names","anchor":"app-names","children":[]},{"title":"Determining the version","anchor":"determining-the-version","children":[]},{"title":"Displaying debug output","anchor":"displaying-debug-output","children":[]}]},{"title":"Available commands","anchor":"available-commands","children":[{"title":"check","anchor":"check","children":[]},{"title":"compilemessages","anchor":"compilemessages","children":[]},{"title":"createcachetable","anchor":"createcachetable","children":[]},{"title":"dbshell","anchor":"dbshell","children":[]},{"title":"diffsettings","anchor":"diffsettings","children":[]},{"title":"dumpdata","anchor":"dumpdata","children":[]},{"title":"flush","anchor":"flush","children":[]},{"title":"inspectdb","anchor":"inspectdb","children":[{"title":"特定于数据库的注释","anchor":"database-specific-notes","children":[{"title":"Oracle","anchor":"oracle","children":[]},{"title":"PostgreSQL","anchor":"postgresql","children":[]}]}]},{"title":"loaddata","anchor":"loaddata","children":[{"title":"What's a \"fixture\"?","anchor":"what-s-a-fixture","children":[]},{"title":"Compressed fixtures","anchor":"compressed-fixtures","children":[]},{"title":"Database-specific fixtures","anchor":"database-specific-fixtures","children":[]},{"title":"Loading fixtures from stdin","anchor":"loading-fixtures-from-stdin","children":[]}]},{"title":"makemessages","anchor":"makemessages","children":[]},{"title":"makemigrations","anchor":"makemigrations","children":[]},{"title":"migrate","anchor":"migrate","children":[]},{"title":"runserver","anchor":"runserver","children":[{"title":"Examples of using different ports and addresses","anchor":"examples-of-using-different-ports-and-addresses","children":[]},{"title":"Serving static files with the development server","anchor":"serving-static-files-with-the-development-server","children":[]}]},{"title":"sendtestemail","anchor":"sendtestemail","children":[]},{"title":"shell","anchor":"shell","children":[]},{"title":"showmigrations","anchor":"showmigrations","children":[]},{"title":"sqlflush","anchor":"sqlflush","children":[]},{"title":"sqlmigrate","anchor":"sqlmigrate","children":[]},{"title":"sqlsequencereset","anchor":"sqlsequencereset","children":[]},{"title":"squashmigrations","anchor":"squashmigrations","children":[]},{"title":"startapp","anchor":"startapp","children":[]},{"title":"startproject","anchor":"startproject","children":[]},{"title":"test","anchor":"test","children":[{"title":"Test runner options","anchor":"test-runner-options","children":[]}]},{"title":"testserver","anchor":"testserver","children":[]}]},{"title":"Commands provided by applications","anchor":"commands-provided-by-applications","children":[{"title":"django.contrib.auth","anchor":"django-contrib-auth","children":[{"title":"changepassword","anchor":"changepassword","children":[]},{"title":"createsuperuser","anchor":"createsuperuser","children":[]}]},{"title":"django.contrib.contenttypes","anchor":"django-contrib-contenttypes","children":[{"title":"remove_stale_contenttypes","anchor":"remove-stale-contenttypes","children":[]}]},{"title":"django.contrib.gis","anchor":"django-contrib-gis","children":[{"title":"ogrinspect","anchor":"ogrinspect","children":[]}]},{"title":"django.contrib.sessions","anchor":"django-contrib-sessions","children":[{"title":"clearsessions","anchor":"clearsessions","children":[]}]},{"title":"django.contrib.sitemaps","anchor":"django-contrib-sitemaps","children":[{"title":"ping_google","anchor":"ping-google","children":[]}]},{"title":"django.contrib.staticfiles","anchor":"django-contrib-staticfiles","children":[{"title":"collectstatic","anchor":"collectstatic","children":[]},{"title":"findstatic","anchor":"findstatic","children":[]}]}]},{"title":"Default options","anchor":"default-options","children":[]},{"title":"Extra niceties","anchor":"extra-niceties","children":[{"title":"Syntax coloring","anchor":"syntax-coloring","children":[]},{"title":"Bash completion","anchor":"bash-completion","children":[]}]}]},{"title":"Running management commands from your code","anchor":"running-management-commands-from-your-code","children":[{"title":"Output redirection","anchor":"output-redirection","children":[]}]}],"breadcrumbs":[{"docname":"ref/index","title":"API参考","url":"/zh-hans/2.2/ref/"}],"prev":{"docname":"ref/databases","title":"Databases","url":"/zh-hans/2.2/ref/databases/"},"next":{"docname":"ref/exceptions","title":"Django Exceptions","url":"/zh-hans/2.2/ref/exceptions/"},"formats":{"html":"/zh-hans/2.2/ref/django-admin/","markdown":"/zh-hans/2.2/ref/django-admin.md","json":"/zh-hans/2.2/ref/django-admin.json"},"source":"https://github.com/django/django/blob/stable/2.2.x/docs/ref/django-admin.txt","official":"https://docs.djangoproject.com/zh-hans/2.2/ref/django-admin/","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"]}