Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates > by-pkgid > 65530c6176058f9b54858c3b4f6385e6 > files > 752

python-django-doc-1.8.19-1.mga6.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" lang="">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>django-admin and manage.py &#8212; Django 1.8.19 documentation</title>
    
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.8.19',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="top" title="Django 1.8.19 documentation" href="../contents.html" />
    <link rel="up" title="API Reference" href="index.html" />
    <link rel="next" title="Django Exceptions" href="exceptions.html" />
    <link rel="prev" title="Databases" href="databases.html" />



 
<script type="text/javascript" src="../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head>
  <body role="document">

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../index.html">Django 1.8.19 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../index.html">Home</a>  |
        <a title="Table of contents" href="../contents.html">Table of contents</a>  |
        <a title="Global index" href="../genindex.html">Index</a>  |
        <a title="Module index" href="../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="databases.html" title="Databases">previous</a>
     |
    <a href="index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="exceptions.html" title="Django Exceptions">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-django-admin">
            
  <div class="section" id="s-django-admin-and-manage-py">
<span id="django-admin-and-manage-py"></span><h1>django-admin and manage.py<a class="headerlink" href="#django-admin-and-manage-py" title="Permalink to this headline">¶</a></h1>
<p><code class="docutils literal"><span class="pre">django-admin</span></code> is Django&#8217;s command-line utility for administrative tasks.
This document outlines all it can do.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.7:</span> <p>Prior to Django 1.7, <code class="docutils literal"><span class="pre">django-admin</span></code> was only installed as
<code class="docutils literal"><span class="pre">django-admin.py</span></code>.</p>
</div>
<p>In addition, <code class="docutils literal"><span class="pre">manage.py</span></code> is automatically created in each Django project.
<code class="docutils literal"><span class="pre">manage.py</span></code> does the same thing as <code class="docutils literal"><span class="pre">django-admin</span></code> but takes care of a few
things for you:</p>
<ul class="simple">
<li>It puts your project&#8217;s package on <code class="docutils literal"><span class="pre">sys.path</span></code>.</li>
<li>It sets the <span class="target" id="index-0"></span><a class="reference internal" href="../topics/settings.html#envvar-DJANGO_SETTINGS_MODULE"><code class="xref std std-envvar docutils literal"><span class="pre">DJANGO_SETTINGS_MODULE</span></code></a> environment variable so that
it points to your project&#8217;s <code class="docutils literal"><span class="pre">settings.py</span></code> file.</li>
</ul>
<p>The <code class="docutils literal"><span class="pre">django-admin</span></code> script should be on your system path if you installed
Django via its <code class="docutils literal"><span class="pre">setup.py</span></code> utility. If it&#8217;s not on your path, you can find it
in <code class="docutils literal"><span class="pre">site-packages/django/bin</span></code> within your Python installation. Consider
symlinking it from some place on your path, such as <code class="docutils literal"><span class="pre">/usr/local/bin</span></code>.</p>
<p>For Windows users, who do not have symlinking functionality available, you can
copy <code class="docutils literal"><span class="pre">django-admin.exe</span></code> to a location on your existing path or edit the
<code class="docutils literal"><span class="pre">PATH</span></code> settings (under <code class="docutils literal"><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>
<span class="pre">Environment...</span></code>) to point to its installed location.</p>
<p>Generally, when working on a single Django project, it&#8217;s easier to use
<code class="docutils literal"><span class="pre">manage.py</span></code> than <code class="docutils literal"><span class="pre">django-admin</span></code>. If you need to switch between multiple
Django settings files, use <code class="docutils literal"><span class="pre">django-admin</span></code> with
<span class="target" id="index-1"></span><a class="reference internal" href="../topics/settings.html#envvar-DJANGO_SETTINGS_MODULE"><code class="xref std std-envvar docutils literal"><span class="pre">DJANGO_SETTINGS_MODULE</span></code></a> or the <a class="reference internal" href="#django-admin-option---settings"><code class="xref std std-djadminopt docutils literal"><span class="pre">--settings</span></code></a> command line
option.</p>
<p>The command-line examples throughout this document use <code class="docutils literal"><span class="pre">django-admin</span></code> to
be consistent, but any example can use <code class="docutils literal"><span class="pre">manage.py</span></code> just as well.</p>
<div class="section" id="s-usage">
<span id="usage"></span><h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<div class="highlight-console"><div class="highlight"><pre><span></span><span class="gp">$</span> django-admin &lt;command&gt; <span class="o">[</span>options<span class="o">]</span>
<span class="gp">$</span> manage.py &lt;command&gt; <span class="o">[</span>options<span class="o">]</span>
</pre></div>
</div>
<p><code class="docutils literal"><span class="pre">command</span></code> should be one of the commands listed in this document.
<code class="docutils literal"><span class="pre">options</span></code>, which is optional, should be zero or more of the options available
for the given command.</p>
<div class="section" id="s-getting-runtime-help">
<span id="getting-runtime-help"></span><h3>Getting runtime help<a class="headerlink" href="#getting-runtime-help" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-help">
<code class="descname">django-admin help</code><a class="headerlink" href="#django-admin-help" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Run <code class="docutils literal"><span class="pre">django-admin</span> <span class="pre">help</span></code> to display usage information and a list of the
commands provided by each application.</p>
<p>Run <code class="docutils literal"><span class="pre">django-admin</span> <span class="pre">help</span> <span class="pre">--commands</span></code> to display a list of all available
commands.</p>
<p>Run <code class="docutils literal"><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
command and a list of its available options.</p>
</div>
<div class="section" id="s-app-names">
<span id="app-names"></span><h3>App names<a class="headerlink" href="#app-names" title="Permalink to this headline">¶</a></h3>
<p>Many commands take a list of &#8220;app names.&#8221; An &#8220;app name&#8221; is the basename of
the package containing your models. For example, if your <a class="reference internal" href="settings.html#std:setting-INSTALLED_APPS"><code class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></code></a>
contains the string <code class="docutils literal"><span class="pre">'mysite.blog'</span></code>, the app name is <code class="docutils literal"><span class="pre">blog</span></code>.</p>
</div>
<div class="section" id="s-determining-the-version">
<span id="determining-the-version"></span><h3>Determining the version<a class="headerlink" href="#determining-the-version" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-version">
<code class="descname">django-admin version</code><a class="headerlink" href="#django-admin-version" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Run <code class="docutils literal"><span class="pre">django-admin</span> <span class="pre">version</span></code> to display the current Django version.</p>
<p>The output follows the schema described in <span class="target" id="index-2"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0386"><strong>PEP 386</strong></a>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="mf">1.4</span><span class="o">.</span><span class="n">dev17026</span>
<span class="mf">1.4</span><span class="n">a1</span>
<span class="mf">1.4</span>
</pre></div>
</div>
</div>
<div class="section" id="s-displaying-debug-output">
<span id="displaying-debug-output"></span><h3>Displaying debug output<a class="headerlink" href="#displaying-debug-output" title="Permalink to this headline">¶</a></h3>
<p>Use <a class="reference internal" href="#django-admin-option---verbosity"><code class="xref std std-djadminopt docutils literal"><span class="pre">--verbosity</span></code></a> to specify the amount of notification and debug information
that <code class="docutils literal"><span class="pre">django-admin</span></code> should print to the console. For more details, see the
documentation for the <a class="reference internal" href="#django-admin-option---verbosity"><code class="xref std std-djadminopt docutils literal"><span class="pre">--verbosity</span></code></a> option.</p>
</div>
</div>
<div class="section" id="s-available-commands">
<span id="available-commands"></span><h2>Available commands<a class="headerlink" href="#available-commands" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-check-appname-appname">
<span id="check-appname-appname"></span><h3>check &lt;appname appname ...&gt;<a class="headerlink" href="#check-appname-appname" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-check">
<code class="descname">django-admin check</code><a class="headerlink" href="#django-admin-check" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionchanged">
<span class="title">Changed in Django 1.7.</span> </div>
<p>Uses the <a class="reference internal" href="checks.html"><span class="doc">system check framework</span></a> to inspect
the entire Django project for common problems.</p>
<p>The system check framework will confirm that there aren&#8217;t any problems with
your installed models or your admin registrations. It will also provide warnings
of common compatibility problems introduced by upgrading Django to a new version.
Custom checks may be introduced by other libraries and applications.</p>
<p>By default, all apps will be checked. You can check a subset of apps by providing
a list of app labels as arguments:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">manage</span><span class="o">.</span><span class="n">py</span> <span class="n">check</span> <span class="n">auth</span> <span class="n">admin</span> <span class="n">myapp</span>
</pre></div>
</div>
<p>If you do not specify any app, all apps will be checked.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---tag">
<code class="descname">--tag</code><code class="descclassname"> &lt;tagname&gt;</code><a class="headerlink" href="#django-admin-option---tag" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <a class="reference internal" href="checks.html"><span class="doc">system check framework</span></a> performs many different
types of checks. These check types are categorized with tags. You can use these tags
to restrict the checks performed to just those in a particular category. For example,
to perform only security and compatibility checks, you would run:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">manage</span><span class="o">.</span><span class="n">py</span> <span class="n">check</span> <span class="o">--</span><span class="n">tag</span> <span class="n">security</span> <span class="o">--</span><span class="n">tag</span> <span class="n">compatibility</span>
</pre></div>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---list-tags">
<code class="descname">--list-tags</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---list-tags" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>List all available tags.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---deploy">
<code class="descname">--deploy</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---deploy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>The <code class="docutils literal"><span class="pre">--deploy</span></code> option activates some additional checks that are only relevant
in a deployment setting.</p>
<p>You can use this option in your local development environment, but since your
local development settings module may not have many of your production settings,
you will probably want to point the <code class="docutils literal"><span class="pre">check</span></code> command at a different settings
module, either by setting the <code class="docutils literal"><span class="pre">DJANGO_SETTINGS_MODULE</span></code> environment variable,
or by passing the <code class="docutils literal"><span class="pre">--settings</span></code> option:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">manage</span><span class="o">.</span><span class="n">py</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>
</pre></div>
</div>
<p>Or you could run it directly on a production or staging deployment to verify
that the correct settings are in use (omitting <code class="docutils literal"><span class="pre">--settings</span></code>). You could even
make it part of your integration test suite.</p>
</div>
<div class="section" id="s-compilemessages">
<span id="compilemessages"></span><h3>compilemessages<a class="headerlink" href="#compilemessages" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-compilemessages">
<code class="descname">django-admin compilemessages</code><a class="headerlink" href="#django-admin-compilemessages" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Compiles .po files created by <a class="reference internal" href="#django-admin-makemessages"><code class="xref std std-djadmin docutils literal"><span class="pre">makemessages</span></code></a> to .mo files for use with
the builtin gettext support. See <a class="reference internal" href="../topics/i18n/index.html"><span class="doc">Internationalization and localization</span></a>.</p>
<p>Use the <a class="reference internal" href="#django-admin-option---locale"><code class="xref std std-djadminopt docutils literal"><span class="pre">--locale</span></code></a> option (or its shorter version <code class="docutils literal"><span class="pre">-l</span></code>) to
specify the locale(s) to process. If not provided, all locales are processed.</p>
<p>Use the <a class="reference internal" href="#django-admin-option---exclude"><code class="xref std std-djadminopt docutils literal"><span class="pre">--exclude</span></code></a> option (or its shorter version <code class="docutils literal"><span class="pre">-x</span></code>) to
specify the locale(s) to exclude from processing. If not provided, no locales
are excluded.</p>
<p>You can pass <code class="docutils literal"><span class="pre">--use-fuzzy</span></code> option (or <code class="docutils literal"><span class="pre">-f</span></code>) to include fuzzy translations
into compiled files.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.8:</span> <p>Added <code class="docutils literal"><span class="pre">--exclude</span></code> and <code class="docutils literal"><span class="pre">--use-fuzzy</span></code> options.</p>
</div>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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="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>
<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="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>
<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="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>
<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="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>
</pre></div>
</div>
</div>
<div class="section" id="s-createcachetable">
<span id="createcachetable"></span><h3>createcachetable<a class="headerlink" href="#createcachetable" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-createcachetable">
<code class="descname">django-admin createcachetable</code><a class="headerlink" href="#django-admin-createcachetable" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Creates the cache tables for use with the database cache backend. See
<a class="reference internal" href="../topics/cache.html"><span class="doc">Django&#8217;s cache framework</span></a> for more information.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database
onto which the cachetable will be installed.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.7:</span> <p>It is no longer necessary to provide the cache table name or the
<a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option. Django takes this information from your
settings file. If you have configured multiple caches or multiple databases,
all cache tables are created.</p>
</div>
</div>
<div class="section" id="s-dbshell">
<span id="dbshell"></span><h3>dbshell<a class="headerlink" href="#dbshell" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-dbshell">
<code class="descname">django-admin dbshell</code><a class="headerlink" href="#django-admin-dbshell" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Runs the command-line client for the database engine specified in your
<code class="docutils literal"><span class="pre">ENGINE</span></code> setting, with the connection parameters specified in your
<a class="reference internal" href="settings.html#std:setting-USER"><code class="xref std std-setting docutils literal"><span class="pre">USER</span></code></a>, <a class="reference internal" href="settings.html#std:setting-PASSWORD"><code class="xref std std-setting docutils literal"><span class="pre">PASSWORD</span></code></a>, etc., settings.</p>
<ul class="simple">
<li>For PostgreSQL, this runs the <code class="docutils literal"><span class="pre">psql</span></code> command-line client.</li>
<li>For MySQL, this runs the <code class="docutils literal"><span class="pre">mysql</span></code> command-line client.</li>
<li>For SQLite, this runs the <code class="docutils literal"><span class="pre">sqlite3</span></code> command-line client.</li>
<li>For Oracle, this runs the <code class="docutils literal"><span class="pre">sqlplus</span></code> command-line client.</li>
</ul>
<p>This command assumes the programs are on your <code class="docutils literal"><span class="pre">PATH</span></code> so that a simple call to
the program name (<code class="docutils literal"><span class="pre">psql</span></code>, <code class="docutils literal"><span class="pre">mysql</span></code>, <code class="docutils literal"><span class="pre">sqlite3</span></code>, <code class="docutils literal"><span class="pre">sqlplus</span></code>) will find the
program in the right place. There&#8217;s no way to specify the location of the
program manually.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database
onto which to open a shell.</p>
</div>
<div class="section" id="s-diffsettings">
<span id="diffsettings"></span><h3>diffsettings<a class="headerlink" href="#diffsettings" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-diffsettings">
<code class="descname">django-admin diffsettings</code><a class="headerlink" href="#django-admin-diffsettings" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Displays differences between the current settings file and Django&#8217;s default
settings.</p>
<p>Settings that don&#8217;t appear in the defaults are followed by <code class="docutils literal"><span class="pre">&quot;###&quot;</span></code>. For
example, the default settings don&#8217;t define <a class="reference internal" href="settings.html#std:setting-ROOT_URLCONF"><code class="xref std std-setting docutils literal"><span class="pre">ROOT_URLCONF</span></code></a>, so
<a class="reference internal" href="settings.html#std:setting-ROOT_URLCONF"><code class="xref std std-setting docutils literal"><span class="pre">ROOT_URLCONF</span></code></a> is followed by <code class="docutils literal"><span class="pre">&quot;###&quot;</span></code> in the output of
<code class="docutils literal"><span class="pre">diffsettings</span></code>.</p>
<p>The <a class="reference internal" href="#django-admin-option---all"><code class="xref std std-djadminopt docutils literal"><span class="pre">--all</span></code></a> option may be provided to display all settings, even
if they have Django&#8217;s default value. Such settings are prefixed by <code class="docutils literal"><span class="pre">&quot;###&quot;</span></code>.</p>
</div>
<div class="section" id="s-dumpdata-app-label-app-label-app-label-model">
<span id="dumpdata-app-label-app-label-app-label-model"></span><h3>dumpdata &lt;app_label app_label app_label.Model ...&gt;<a class="headerlink" href="#dumpdata-app-label-app-label-app-label-model" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-dumpdata">
<code class="descname">django-admin dumpdata</code><a class="headerlink" href="#django-admin-dumpdata" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Outputs to standard output all data in the database associated with the named
application(s).</p>
<p>If no application name is provided, all installed applications will be dumped.</p>
<p>The output of <code class="docutils literal"><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"><span class="pre">loaddata</span></code></a>.</p>
<p>Note that <code class="docutils literal"><span class="pre">dumpdata</span></code> uses the default manager on the model for selecting the
records to dump. If you&#8217;re using a <a class="reference internal" href="../topics/db/managers.html#custom-managers"><span class="std std-ref">custom manager</span></a> as
the default manager and it filters some of the available records, not all of the
objects will be dumped.</p>
<p>The <a class="reference internal" href="#django-admin-option---all"><code class="xref std std-djadminopt docutils literal"><span class="pre">--all</span></code></a> option may be provided to specify that
<code class="docutils literal"><span class="pre">dumpdata</span></code> should use Django&#8217;s base manager, dumping records which
might otherwise be filtered or modified by a custom manager.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---format">
<code class="descname">--format</code><code class="descclassname"> &lt;fmt&gt;</code><a class="headerlink" href="#django-admin-option---format" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>By default, <code class="docutils literal"><span class="pre">dumpdata</span></code> will format its output in JSON, but you can use the
<code class="docutils literal"><span class="pre">--format</span></code> option to specify another format. Currently supported formats
are listed in <a class="reference internal" href="../topics/serialization.html#serialization-formats"><span class="std std-ref">Serialization formats</span></a>.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---indent">
<code class="descname">--indent</code><code class="descclassname"> &lt;num&gt;</code><a class="headerlink" href="#django-admin-option---indent" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>By default, <code class="docutils literal"><span class="pre">dumpdata</span></code> will output all data on a single line. This isn&#8217;t
easy for humans to read, so you can use the <code class="docutils literal"><span class="pre">--indent</span></code> option to
pretty-print the output with a number of indentation spaces.</p>
<p>The <a class="reference internal" href="#django-admin-option---exclude"><code class="xref std std-djadminopt docutils literal"><span class="pre">--exclude</span></code></a> option may be provided to prevent specific
applications or models (specified as in the form of <code class="docutils literal"><span class="pre">app_label.ModelName</span></code>)
from being dumped. If you specify a model name to <code class="docutils literal"><span class="pre">dumpdata</span></code>, the dumped
output will be restricted to that model, rather than the entire application.
You can also mix application names and model names.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database
from which data will be dumped.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---natural-foreign">
<code class="descname">--natural-foreign</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---natural-foreign" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.7.</span> </div>
<p>When this option is specified, Django will use the <code class="docutils literal"><span class="pre">natural_key()</span></code> model
method to serialize any foreign key and many-to-many relationship to objects of
the type that defines the method. If you are dumping <code class="docutils literal"><span class="pre">contrib.auth</span></code>
<code class="docutils literal"><span class="pre">Permission</span></code> objects or <code class="docutils literal"><span class="pre">contrib.contenttypes</span></code> <code class="docutils literal"><span class="pre">ContentType</span></code> objects, you
should probably be using this flag. See the <a class="reference internal" href="../topics/serialization.html#topics-serialization-natural-keys"><span class="std std-ref">natural keys</span></a> documentation for more details on this
and the next option.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---natural-primary">
<code class="descname">--natural-primary</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---natural-primary" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.7.</span> </div>
<p>When this option is specified, Django will not provide the primary key in the
serialized data of this object since it can be calculated during
deserialization.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---natural">
<code class="descname">--natural</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---natural" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 1.7: </span>Equivalent to the <a class="reference internal" href="#django-admin-option---natural-foreign"><code class="xref std std-djadminopt docutils literal"><span class="pre">--natural-foreign</span></code></a> option; use that instead.</p>
</div>
<p>Use <a class="reference internal" href="../topics/serialization.html#topics-serialization-natural-keys"><span class="std std-ref">natural keys</span></a> to represent
any foreign key and many-to-many relationship with a model that provides
a natural key definition.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---pks">
<code class="descname">--pks</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---pks" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>By default, <code class="docutils literal"><span class="pre">dumpdata</span></code> will output all the records of the model, but
you can use the <code class="docutils literal"><span class="pre">--pks</span></code> option to specify a comma separated list of
primary keys on which to filter.  This is only available when dumping
one model.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---output">
<code class="descname">--output</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---output" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>By default <code class="docutils literal"><span class="pre">dumpdata</span></code> will output all the serialized data to standard output.
This option allows you to specify the file to which the data is to be written.</p>
</div>
<div class="section" id="s-flush">
<span id="flush"></span><h3>flush<a class="headerlink" href="#flush" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-flush">
<code class="descname">django-admin flush</code><a class="headerlink" href="#django-admin-flush" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Removes all data from the database, re-executes any post-synchronization
handlers, and reinstalls any initial data fixtures.</p>
<p>The <a class="reference internal" href="#django-admin-option---noinput"><code class="xref std std-djadminopt docutils literal"><span class="pre">--noinput</span></code></a> option may be provided to suppress all user
prompts.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option may be used to specify the database
to flush.</p>
<div class="section" id="s-no-initial-data">
<span id="no-initial-data"></span><h4><code class="docutils literal"><span class="pre">--no-initial-data</span></code><a class="headerlink" href="#no-initial-data" title="Permalink to this headline">¶</a></h4>
<p>Use <code class="docutils literal"><span class="pre">--no-initial-data</span></code> to avoid loading the initial_data fixture.</p>
</div>
</div>
<div class="section" id="s-inspectdb">
<span id="inspectdb"></span><h3>inspectdb<a class="headerlink" href="#inspectdb" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-inspectdb">
<code class="descname">django-admin inspectdb</code><a class="headerlink" href="#django-admin-inspectdb" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Introspects the database tables in the database pointed-to by the
<a class="reference internal" href="settings.html#std:setting-NAME"><code class="xref std std-setting docutils literal"><span class="pre">NAME</span></code></a> setting and outputs a Django model module (a <code class="docutils literal"><span class="pre">models.py</span></code>
file) to standard output.</p>
<p>Use this if you have a legacy database with which you&#8217;d like to use Django.
The script will inspect the database and create a model for each table within
it.</p>
<p>As you might expect, the created models will have an attribute for every field
in the table. Note that <code class="docutils literal"><span class="pre">inspectdb</span></code> has a few special cases in its field-name
output:</p>
<ul class="simple">
<li>If <code class="docutils literal"><span class="pre">inspectdb</span></code> cannot map a column&#8217;s type to a model field type, it&#8217;ll
use <code class="docutils literal"><span class="pre">TextField</span></code> and will insert the Python comment
<code class="docutils literal"><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
model.</li>
<li>If the database column name is a Python reserved word (such as
<code class="docutils literal"><span class="pre">'pass'</span></code>, <code class="docutils literal"><span class="pre">'class'</span></code> or <code class="docutils literal"><span class="pre">'for'</span></code>), <code class="docutils literal"><span class="pre">inspectdb</span></code> will append
<code class="docutils literal"><span class="pre">'_field'</span></code> to the attribute name. For example, if a table has a column
<code class="docutils literal"><span class="pre">'for'</span></code>, the generated model will have a field <code class="docutils literal"><span class="pre">'for_field'</span></code>, with
the <code class="docutils literal"><span class="pre">db_column</span></code> attribute set to <code class="docutils literal"><span class="pre">'for'</span></code>. <code class="docutils literal"><span class="pre">inspectdb</span></code> will insert
the Python comment
<code class="docutils literal"><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
field.</li>
</ul>
<p>This feature is meant as a shortcut, not as definitive model generation. After
you run it, you&#8217;ll want to look over the generated models yourself to make
customizations. In particular, you&#8217;ll need to rearrange models&#8217; order, so that
models that refer to other models are ordered properly.</p>
<p>Primary keys are automatically introspected for PostgreSQL, MySQL and
SQLite, in which case Django puts in the <code class="docutils literal"><span class="pre">primary_key=True</span></code> where
needed.</p>
<p><code class="docutils literal"><span class="pre">inspectdb</span></code> works with PostgreSQL, MySQL and SQLite. Foreign-key detection
only works in PostgreSQL and with certain types of MySQL tables.</p>
<p>Django doesn&#8217;t create database defaults when a
<a class="reference internal" href="models/fields.html#django.db.models.Field.default" title="django.db.models.Field.default"><code class="xref py py-attr docutils literal"><span class="pre">default</span></code></a> is specified on a model field.
Similarly, database defaults aren&#8217;t translated to model field defaults or
detected in any fashion by <code class="docutils literal"><span class="pre">inspectdb</span></code>.</p>
<p>By default, <code class="docutils literal"><span class="pre">inspectdb</span></code> creates unmanaged models. That is, <code class="docutils literal"><span class="pre">managed</span> <span class="pre">=</span> <span class="pre">False</span></code>
in the model&#8217;s <code class="docutils literal"><span class="pre">Meta</span></code> class tells Django not to manage each table&#8217;s creation,
modification, and deletion. If you do want to allow Django to manage the
table&#8217;s lifecycle, you&#8217;ll need to change the
<a class="reference internal" href="models/options.html#django.db.models.Options.managed" title="django.db.models.Options.managed"><code class="xref py py-attr docutils literal"><span class="pre">managed</span></code></a> option to <code class="docutils literal"><span class="pre">True</span></code> (or simply remove
it because <code class="docutils literal"><span class="pre">True</span></code> is its default value).</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option may be used to specify the
database to introspect.</p>
</div>
<div class="section" id="s-loaddata-fixture-fixture">
<span id="loaddata-fixture-fixture"></span><h3>loaddata &lt;fixture fixture ...&gt;<a class="headerlink" href="#loaddata-fixture-fixture" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-loaddata">
<code class="descname">django-admin loaddata</code><a class="headerlink" href="#django-admin-loaddata" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Searches for and loads the contents of the named fixture into the database.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database
onto which the data will be loaded.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---ignorenonexistent">
<code class="descname">--ignorenonexistent</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---ignorenonexistent" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <a class="reference internal" href="#django-admin-option---ignorenonexistent"><code class="xref std std-djadminopt docutils literal"><span class="pre">--ignorenonexistent</span></code></a> option can be used to ignore fields and
models that may have been removed since the fixture was originally generated.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---app">
<code class="descname">--app</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---app" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <a class="reference internal" href="#django-admin-option---app"><code class="xref std std-djadminopt docutils literal"><span class="pre">--app</span></code></a> option can be used to specify a single app to look
for fixtures in rather than looking through all apps.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.7:</span> <p><code class="docutils literal"><span class="pre">--app</span></code> was added.</p>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.8:</span> <p><code class="docutils literal"><span class="pre">--ignorenonexistent</span></code> also ignores non-existent models.</p>
</div>
<div class="section" id="s-what-s-a-fixture">
<span id="what-s-a-fixture"></span><h4>What&#8217;s a &#8220;fixture&#8221;?<a class="headerlink" href="#what-s-a-fixture" title="Permalink to this headline">¶</a></h4>
<p>A <em>fixture</em> is a collection of files that contain the serialized contents of
the database. Each fixture has a unique name, and the files that comprise the
fixture can be distributed over multiple directories, in multiple applications.</p>
<p>Django will search in three locations for fixtures:</p>
<ol class="arabic simple">
<li>In the <code class="docutils literal"><span class="pre">fixtures</span></code> directory of every installed application</li>
<li>In any directory named in the <a class="reference internal" href="settings.html#std:setting-FIXTURE_DIRS"><code class="xref std std-setting docutils literal"><span class="pre">FIXTURE_DIRS</span></code></a> setting</li>
<li>In the literal path named by the fixture</li>
</ol>
<p>Django will load any and all fixtures it finds in these locations that match
the provided fixture names.</p>
<p>If the named fixture has a file extension, only fixtures of that type
will be loaded. For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>would only load JSON fixtures called <code class="docutils literal"><span class="pre">mydata</span></code>. The fixture extension
must correspond to the registered name of a
<a class="reference internal" href="../topics/serialization.html#serialization-formats"><span class="std std-ref">serializer</span></a> (e.g., <code class="docutils literal"><span class="pre">json</span></code> or <code class="docutils literal"><span class="pre">xml</span></code>).</p>
<p>If you omit the extensions, Django will search all available fixture types
for a matching fixture. For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">django</span><span class="o">-</span><span class="n">admin</span> <span class="n">loaddata</span> <span class="n">mydata</span>
</pre></div>
</div>
<p>would look for any fixture of any fixture type called <code class="docutils literal"><span class="pre">mydata</span></code>. If a fixture
directory contained <code class="docutils literal"><span class="pre">mydata.json</span></code>, that fixture would be loaded
as a JSON fixture.</p>
<p>The fixtures that are named can include directory components. These
directories will be included in the search path. For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>would search <code class="docutils literal"><span class="pre">&lt;app_label&gt;/fixtures/foo/bar/mydata.json</span></code> for each installed
application,  <code class="docutils literal"><span class="pre">&lt;dirname&gt;/foo/bar/mydata.json</span></code> for each directory in
<a class="reference internal" href="settings.html#std:setting-FIXTURE_DIRS"><code class="xref std std-setting docutils literal"><span class="pre">FIXTURE_DIRS</span></code></a>, and the literal path <code class="docutils literal"><span class="pre">foo/bar/mydata.json</span></code>.</p>
<p>When fixture files are processed, the data is saved to the database as is.
Model defined <a class="reference internal" href="models/instances.html#django.db.models.Model.save" title="django.db.models.Model.save"><code class="xref py py-meth docutils literal"><span class="pre">save()</span></code></a> methods are not called, and
any <a class="reference internal" href="signals.html#django.db.models.signals.pre_save" title="django.db.models.signals.pre_save"><code class="xref py py-data docutils literal"><span class="pre">pre_save</span></code></a> or
<a class="reference internal" href="signals.html#django.db.models.signals.post_save" title="django.db.models.signals.post_save"><code class="xref py py-data docutils literal"><span class="pre">post_save</span></code></a> signals will be called with
<code class="docutils literal"><span class="pre">raw=True</span></code> since the instance only contains attributes that are local to the
model. You may, for example, want to disable handlers that access
related fields that aren&#8217;t present during fixture loading and would otherwise
raise an exception:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.db.models.signals</span> <span class="k">import</span> <span class="n">post_save</span>
<span class="kn">from</span> <span class="nn">.models</span> <span class="k">import</span> <span class="n">MyModel</span>

<span class="k">def</span> <span class="nf">my_handler</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="c1"># disable the handler during fixture loading</span>
    <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>
        <span class="k">return</span>
    <span class="o">...</span>

<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>
</pre></div>
</div>
<p>You could also write a simple decorator to encapsulate this logic:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">functools</span> <span class="k">import</span> <span class="n">wraps</span>

<span class="k">def</span> <span class="nf">disable_for_loaddata</span><span class="p">(</span><span class="n">signal_handler</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Decorator that turns off signal handlers when loading fixture data.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="nd">@wraps</span><span class="p">(</span><span class="n">signal_handler</span><span class="p">)</span>
    <span class="k">def</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>
        <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>
            <span class="k">return</span>
        <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>
    <span class="k">return</span> <span class="n">wrapper</span>

<span class="nd">@disable_for_loaddata</span>
<span class="k">def</span> <span class="nf">my_handler</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="o">...</span>
</pre></div>
</div>
<p>Just be aware that this logic will disable the signals whenever fixtures are
deserialized, not just during <code class="docutils literal"><span class="pre">loaddata</span></code>.</p>
<p>Note that the order in which fixture files are processed is undefined. However,
all fixture data is installed as a single transaction, so data in
one fixture can reference data in another fixture. If the database backend
supports row-level constraints, these constraints will be checked at the
end of the transaction.</p>
<p>The <a class="reference internal" href="#django-admin-dumpdata"><code class="xref std std-djadmin docutils literal"><span class="pre">dumpdata</span></code></a> command can be used to generate input for <code class="docutils literal"><span class="pre">loaddata</span></code>.</p>
</div>
<div class="section" id="s-compressed-fixtures">
<span id="compressed-fixtures"></span><h4>Compressed fixtures<a class="headerlink" href="#compressed-fixtures" title="Permalink to this headline">¶</a></h4>
<p>Fixtures may be compressed in <code class="docutils literal"><span class="pre">zip</span></code>, <code class="docutils literal"><span class="pre">gz</span></code>, or <code class="docutils literal"><span class="pre">bz2</span></code> format. For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>would look for any of <code class="docutils literal"><span class="pre">mydata.json</span></code>, <code class="docutils literal"><span class="pre">mydata.json.zip</span></code>,
<code class="docutils literal"><span class="pre">mydata.json.gz</span></code>, or <code class="docutils literal"><span class="pre">mydata.json.bz2</span></code>. The first file contained within a
zip-compressed archive is used.</p>
<p>Note that if two fixtures with the same name but different
fixture type are discovered (for example, if <code class="docutils literal"><span class="pre">mydata.json</span></code> and
<code class="docutils literal"><span class="pre">mydata.xml.gz</span></code> were found in the same fixture directory), fixture
installation will be aborted, and any data installed in the call to
<code class="docutils literal"><span class="pre">loaddata</span></code> will be removed from the database.</p>
<div class="admonition-mysql-with-myisam-and-fixtures admonition">
<p class="first admonition-title">MySQL with MyISAM and fixtures</p>
<p class="last">The MyISAM storage engine of MySQL doesn&#8217;t support transactions or
constraints, so if you use MyISAM, you won&#8217;t get validation of fixture
data, or a rollback if multiple transaction files are found.</p>
</div>
</div>
<div class="section" id="s-database-specific-fixtures">
<span id="database-specific-fixtures"></span><h4>Database-specific fixtures<a class="headerlink" href="#database-specific-fixtures" title="Permalink to this headline">¶</a></h4>
<p>If you&#8217;re in a multi-database setup, you might have fixture data that
you want to load onto one database, but not onto another. In this
situation, you can add a database identifier into the names of your fixtures.</p>
<p>For example, if your <a class="reference internal" href="settings.html#std:setting-DATABASES"><code class="xref std std-setting docutils literal"><span class="pre">DATABASES</span></code></a> setting has a &#8216;master&#8217; database
defined, name the fixture <code class="docutils literal"><span class="pre">mydata.master.json</span></code> or
<code class="docutils literal"><span class="pre">mydata.master.json.gz</span></code> and the fixture will only be loaded when you
specify you want to load data into the <code class="docutils literal"><span class="pre">master</span></code> database.</p>
</div>
</div>
<div class="section" id="s-makemessages">
<span id="makemessages"></span><h3>makemessages<a class="headerlink" href="#makemessages" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-makemessages">
<code class="descname">django-admin makemessages</code><a class="headerlink" href="#django-admin-makemessages" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Runs over the entire source tree of the current directory and pulls out all
strings marked for translation. It creates (or updates) a message file in the
conf/locale (in the Django tree) or locale (for project and application)
directory. After making changes to the messages files you need to compile them
with <a class="reference internal" href="#django-admin-compilemessages"><code class="xref std std-djadmin docutils literal"><span class="pre">compilemessages</span></code></a> for use with the builtin gettext support. See
the <a class="reference internal" href="../topics/i18n/translation.html#how-to-create-language-files"><span class="std std-ref">i18n documentation</span></a> for details.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---all">
<code class="descname">--all</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---all" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--all</span></code> or <code class="docutils literal"><span class="pre">-a</span></code> option to update the message files for all
available languages.</p>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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="nb">all</span>
</pre></div>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---extension">
<code class="descname">--extension</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---extension" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--extension</span></code> or <code class="docutils literal"><span class="pre">-e</span></code> option to specify a list of file extensions
to examine (default: &#8221;.html&#8221;, &#8221;.txt&#8221;).</p>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Separate multiple extensions with commas or use -e or &#8211;extension multiple times:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Use the <a class="reference internal" href="#django-admin-option---locale"><code class="xref std std-djadminopt docutils literal"><span class="pre">--locale</span></code></a> option (or its shorter version <code class="docutils literal"><span class="pre">-l</span></code>) to
specify the locale(s) to process.</p>
<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>Use the <a class="reference internal" href="#django-admin-option---exclude"><code class="xref std std-djadminopt docutils literal"><span class="pre">--exclude</span></code></a> option (or its shorter version <code class="docutils literal"><span class="pre">-x</span></code>) to
specify the locale(s) to exclude from processing. If not provided, no locales
are excluded.</p>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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="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>
<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="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>
<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="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>
<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="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>
</pre></div>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.7:</span> <p>Added the <code class="docutils literal"><span class="pre">--previous</span></code> option to the <code class="docutils literal"><span class="pre">msgmerge</span></code> command when merging
with existing po files.</p>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---domain">
<code class="descname">--domain</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---domain" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--domain</span></code> or <code class="docutils literal"><span class="pre">-d</span></code> option to change the domain of the messages files.
Currently supported:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">django</span></code> for all <code class="docutils literal"><span class="pre">*.py</span></code>, <code class="docutils literal"><span class="pre">*.html</span></code> and <code class="docutils literal"><span class="pre">*.txt</span></code> files (default)</li>
<li><code class="docutils literal"><span class="pre">djangojs</span></code> for <code class="docutils literal"><span class="pre">*.js</span></code> files</li>
</ul>
<dl class="django-admin-option">
<dt id="django-admin-option---symlinks">
<code class="descname">--symlinks</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---symlinks" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--symlinks</span></code> or <code class="docutils literal"><span class="pre">-s</span></code> option to follow symlinks to directories when
looking for new translation strings.</p>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---ignore">
<code class="descname">--ignore</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---ignore" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--ignore</span></code> or <code class="docutils literal"><span class="pre">-i</span></code> option to ignore files or directories matching
the given <code class="xref py py-mod docutils literal"><span class="pre">glob</span></code>-style pattern. Use multiple times to ignore more.</p>
<p>These patterns are used by default: <code class="docutils literal"><span class="pre">'CVS'</span></code>, <code class="docutils literal"><span class="pre">'.*'</span></code>, <code class="docutils literal"><span class="pre">'*~'</span></code>, <code class="docutils literal"><span class="pre">'*.pyc'</span></code></p>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---no-default-ignore">
<code class="descname">--no-default-ignore</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---no-default-ignore" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--no-default-ignore</span></code> option to disable the default values of
<a class="reference internal" href="#django-admin-option---ignore"><code class="xref std std-djadminopt docutils literal"><span class="pre">--ignore</span></code></a>.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---no-wrap">
<code class="descname">--no-wrap</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---no-wrap" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--no-wrap</span></code> option to disable breaking long message lines into
several lines in language files.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---no-location">
<code class="descname">--no-location</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---no-location" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--no-location</span></code> option to suppress writing &#8216;<code class="docutils literal"><span class="pre">#:</span> <span class="pre">filename:line</span></code>’
comment lines in language files. Note that using this option makes it harder
for technically skilled translators to understand each message&#8217;s context.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---keep-pot">
<code class="descname">--keep-pot</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---keep-pot" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--keep-pot</span></code> option to prevent Django from deleting the temporary
<code class="docutils literal"><span class="pre">.pot</span></code> files it generates before creating the .po file. This is useful for
debugging errors which may prevent the final language files from being created.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last">See <a class="reference internal" href="../topics/i18n/translation.html#customizing-makemessages"><span class="std std-ref">Customizing the makemessages command</span></a> for instructions on how to customize
the keywords that <a class="reference internal" href="#django-admin-makemessages"><code class="xref std std-djadmin docutils literal"><span class="pre">makemessages</span></code></a> passes to <code class="docutils literal"><span class="pre">xgettext</span></code>.</p>
</div>
</div>
<div class="section" id="s-makemigrations-app-label">
<span id="makemigrations-app-label"></span><h3>makemigrations [&lt;app_label&gt;]<a class="headerlink" href="#makemigrations-app-label" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-makemigrations">
<code class="descname">django-admin makemigrations</code><a class="headerlink" href="#django-admin-makemigrations" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.7.</span> </div>
<p>Creates new migrations based on the changes detected to your models.
Migrations, their relationship with apps and more are covered in depth in
<a class="reference internal" href="../topics/migrations.html"><span class="doc">the migrations documentation</span></a>.</p>
<p>Providing one or more app names as arguments will limit the migrations created
to the app(s) specified and any dependencies needed (the table at the other end
of a <code class="docutils literal"><span class="pre">ForeignKey</span></code>, for example).</p>
<dl class="django-admin-option">
<dt id="django-admin-option---empty">
<code class="descname">--empty</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---empty" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <code class="docutils literal"><span class="pre">--empty</span></code> option will cause <code class="docutils literal"><span class="pre">makemigrations</span></code> to output an empty
migration for the specified apps, for manual editing. This option is only
for advanced users and should not be used unless you are familiar with
the migration format, migration operations, and the dependencies between
your migrations.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---dry-run">
<code class="descname">--dry-run</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---dry-run" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <code class="docutils literal"><span class="pre">--dry-run</span></code> option shows what migrations would be made without
actually writing any migrations files to disk. Using this option along with
<code class="docutils literal"><span class="pre">--verbosity</span> <span class="pre">3</span></code> will also show the complete migrations files that would be
written.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---merge">
<code class="descname">--merge</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---merge" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <code class="docutils literal"><span class="pre">--merge</span></code> option enables fixing of migration conflicts. The
<a class="reference internal" href="#django-admin-option---noinput"><code class="xref std std-djadminopt docutils literal"><span class="pre">--noinput</span></code></a> option may be provided to suppress user prompts during
a merge.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---name">
<code class="descname">--name</code><code class="descclassname">, -n</code><a class="headerlink" href="#django-admin-option---name" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>The <code class="docutils literal"><span class="pre">--name</span></code> option allows you to give the migration(s) a custom name instead
of a generated one.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---exit">
<code class="descname">--exit</code><code class="descclassname">, -e</code><a class="headerlink" href="#django-admin-option---exit" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>The <code class="docutils literal"><span class="pre">--exit</span></code> option will cause <code class="docutils literal"><span class="pre">makemigrations</span></code> to exit with error code 1
when no migrations are created (or would have been created, if combined with
<code class="docutils literal"><span class="pre">--dry-run</span></code>).</p>
</div>
<div class="section" id="s-migrate-app-label-migrationname">
<span id="migrate-app-label-migrationname"></span><h3>migrate [&lt;app_label&gt; [&lt;migrationname&gt;]]<a class="headerlink" href="#migrate-app-label-migrationname" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-migrate">
<code class="descname">django-admin migrate</code><a class="headerlink" href="#django-admin-migrate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.7.</span> </div>
<p>Synchronizes the database state with the current set of models and migrations.
Migrations, their relationship with apps and more are covered in depth in
<a class="reference internal" href="../topics/migrations.html"><span class="doc">the migrations documentation</span></a>.</p>
<p>The behavior of this command changes depending on the arguments provided:</p>
<ul class="simple">
<li>No arguments: All migrated apps have all of their migrations run,
and all unmigrated apps are synchronized with the database,</li>
<li><code class="docutils literal"><span class="pre">&lt;app_label&gt;</span></code>: The specified app has its migrations run, up to the most
recent migration. This may involve running other apps&#8217; migrations too, due
to dependencies.</li>
<li><code class="docutils literal"><span class="pre">&lt;app_label&gt;</span> <span class="pre">&lt;migrationname&gt;</span></code>: Brings the database schema to a state where
the named migration is applied, but no later migrations in the same app are
applied. This may involve unapplying migrations if you have previously
migrated past the named migration. Use the name <code class="docutils literal"><span class="pre">zero</span></code> to unapply all
migrations for an app.</li>
</ul>
<p>Unlike <code class="docutils literal"><span class="pre">syncdb</span></code>, this command does not prompt you to create a superuser if
one doesn&#8217;t exist (assuming you are using <a class="reference internal" href="../topics/auth/index.html#module-django.contrib.auth" title="django.contrib.auth: Django's authentication framework."><code class="xref py py-mod docutils literal"><span class="pre">django.contrib.auth</span></code></a>). Use
<a class="reference internal" href="#django-admin-createsuperuser"><code class="xref std std-djadmin docutils literal"><span class="pre">createsuperuser</span></code></a> to do that if you wish.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database to
migrate.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---fake">
<code class="descname">--fake</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---fake" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <code class="docutils literal"><span class="pre">--fake</span></code> option tells Django to mark the migrations as having been
applied or unapplied, but without actually running the SQL to change your
database schema.</p>
<p>This is intended for advanced users to manipulate the
current migration state directly if they&#8217;re manually applying changes;
be warned that using <code class="docutils literal"><span class="pre">--fake</span></code> runs the risk of putting the migration state
table into a state where manual recovery will be needed to make migrations
run correctly.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---fake-initial">
<code class="descname">--fake-initial</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---fake-initial" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>The <code class="docutils literal"><span class="pre">--fake-initial</span></code> option can be used to allow Django to skip an app&#8217;s
initial migration if all database tables with the names of all models created
by all <a class="reference internal" href="migration-operations.html#django.db.migrations.operations.CreateModel" title="django.db.migrations.operations.CreateModel"><code class="xref py py-class docutils literal"><span class="pre">CreateModel</span></code></a> operations in that
migration already exist. This option is intended for use when first running
migrations against a database that preexisted the use of migrations. This
option does not, however, check for matching database schema beyond matching
table names and so is only safe to use if you are confident that your existing
schema matches what is recorded in your initial migration.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 1.8: </span>The <code class="docutils literal"><span class="pre">--list</span></code> option has been moved to the <a class="reference internal" href="#django-admin-showmigrations"><code class="xref std std-djadmin docutils literal"><span class="pre">showmigrations</span></code></a>
command.</p>
</div>
</div>
<div class="section" id="s-runfcgi-options">
<span id="runfcgi-options"></span><h3>runfcgi [options]<a class="headerlink" href="#runfcgi-options" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-runfcgi">
<code class="descname">django-admin runfcgi</code><a class="headerlink" href="#django-admin-runfcgi" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 1.7: </span>FastCGI support is deprecated and will be removed in Django 1.9.</p>
</div>
<p>Starts a set of FastCGI processes suitable for use with any Web server that
supports the FastCGI protocol. See the <a class="reference internal" href="../howto/deployment/fastcgi.html"><span class="doc">FastCGI deployment documentation</span></a> for details. Requires the Python FastCGI module from
<a class="reference external" href="http://www.saddi.com/software/flup/">flup</a>.</p>
<p>Internally, this wraps the WSGI application object specified by the
<a class="reference internal" href="settings.html#std:setting-WSGI_APPLICATION"><code class="xref std std-setting docutils literal"><span class="pre">WSGI_APPLICATION</span></code></a> setting.</p>
<p>The options accepted by this command are passed to the FastCGI library and
don&#8217;t use the <code class="docutils literal"><span class="pre">'--'</span></code> prefix as is usual for other Django management commands.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-protocol">
<code class="descname">protocol</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-protocol" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">protocol=PROTOCOL</span></code></p>
<p>Protocol to use. <em>PROTOCOL</em> can be <code class="docutils literal"><span class="pre">fcgi</span></code>, <code class="docutils literal"><span class="pre">scgi</span></code>, <code class="docutils literal"><span class="pre">ajp</span></code>, etc.
(default is <code class="docutils literal"><span class="pre">fcgi</span></code>)</p>
<dl class="django-admin-option">
<dt id="django-admin-option-host">
<code class="descname">host</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-host" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">host=HOSTNAME</span></code></p>
<p>Hostname to listen on.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-port">
<code class="descname">port</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-port" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">port=PORTNUM</span></code></p>
<p>Port to listen on.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-socket">
<code class="descname">socket</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-socket" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">socket=FILE</span></code></p>
<p>UNIX socket to listen on.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-method">
<code class="descname">method</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-method" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">method=IMPL</span></code></p>
<p>Possible values: <code class="docutils literal"><span class="pre">prefork</span></code> or <code class="docutils literal"><span class="pre">threaded</span></code> (default <code class="docutils literal"><span class="pre">prefork</span></code>)</p>
<dl class="django-admin-option">
<dt id="django-admin-option-maxrequests">
<code class="descname">maxrequests</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-maxrequests" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">maxrequests=NUMBER</span></code></p>
<p>Number of requests a child handles before it is killed and a new child is
forked (0 means no limit).</p>
<dl class="django-admin-option">
<dt id="django-admin-option-maxspare">
<code class="descname">maxspare</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-maxspare" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">maxspare=NUMBER</span></code></p>
<p>Max number of spare processes / threads.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-minspare">
<code class="descname">minspare</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-minspare" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">minspare=NUMBER</span></code></p>
<p>Min number of spare processes / threads.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-maxchildren">
<code class="descname">maxchildren</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-maxchildren" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">maxchildren=NUMBER</span></code></p>
<p>Hard limit number of processes / threads.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-daemonize">
<code class="descname">daemonize</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-daemonize" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">daemonize=BOOL</span></code></p>
<p>Whether to detach from terminal.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-pidfile">
<code class="descname">pidfile</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-pidfile" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">pidfile=FILE</span></code></p>
<p>Write the spawned process-id to file <em>FILE</em>.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-workdir">
<code class="descname">workdir</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-workdir" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">workdir=DIRECTORY</span></code></p>
<p>Change to directory <em>DIRECTORY</em> when daemonizing.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-debug">
<code class="descname">debug</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-debug" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">debug=BOOL</span></code></p>
<p>Set to true to enable flup tracebacks.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-outlog">
<code class="descname">outlog</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-outlog" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">outlog=FILE</span></code></p>
<p>Write stdout to the <em>FILE</em> file.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-errlog">
<code class="descname">errlog</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-errlog" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">errlog=FILE</span></code></p>
<p>Write stderr to the <em>FILE</em> file.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-umask">
<code class="descname">umask</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option-umask" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><code class="docutils literal"><span class="pre">umask=UMASK</span></code></p>
<p>Umask to use when daemonizing. The value is interpreted as an octal number
(default value is <code class="docutils literal"><span class="pre">0o22</span></code>).</p>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">django</span><span class="o">-</span><span class="n">admin</span> <span class="n">runfcgi</span> <span class="n">socket</span><span class="o">=/</span><span class="n">tmp</span><span class="o">/</span><span class="n">fcgi</span><span class="o">.</span><span class="n">sock</span> <span class="n">method</span><span class="o">=</span><span class="n">prefork</span> <span class="n">daemonize</span><span class="o">=</span><span class="n">true</span> \
    <span class="n">pidfile</span><span class="o">=/</span><span class="n">var</span><span class="o">/</span><span class="n">run</span><span class="o">/</span><span class="n">django</span><span class="o">-</span><span class="n">fcgi</span><span class="o">.</span><span class="n">pid</span>
</pre></div>
</div>
<p>Run a FastCGI server as a daemon and write the spawned PID in a file.</p>
</div>
<div class="section" id="s-runserver-port-or-address-port">
<span id="runserver-port-or-address-port"></span><h3>runserver [port or address:port]<a class="headerlink" href="#runserver-port-or-address-port" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-runserver">
<code class="descname">django-admin runserver</code><a class="headerlink" href="#django-admin-runserver" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Starts a lightweight development Web server on the local machine. By default,
the server runs on port 8000 on the IP address <code class="docutils literal"><span class="pre">127.0.0.1</span></code>. You can pass in an
IP address and port number explicitly.</p>
<p>If you run this script as a user with normal privileges (recommended), you
might not have access to start a port on a low port number. Low port numbers
are reserved for the superuser (root).</p>
<p>This server uses the WSGI application object specified by the
<a class="reference internal" href="settings.html#std:setting-WSGI_APPLICATION"><code class="xref std std-setting docutils literal"><span class="pre">WSGI_APPLICATION</span></code></a> setting.</p>
<p>DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through
security audits or performance tests. (And that&#8217;s how it&#8217;s gonna stay. We&#8217;re in
the business of making Web frameworks, not Web servers, so improving this
server to be able to handle a production environment is outside the scope of
Django.)</p>
<p>The development server automatically reloads Python code for each request, as
needed. You don&#8217;t need to restart the server for code changes to take effect.
However, some actions like adding files don&#8217;t trigger a restart, so you&#8217;ll
have to restart the server in these cases.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.7:</span> <p>Compiling translation files now also restarts the development server.</p>
</div>
<p>If you are using Linux and install <a class="reference external" href="https://pypi.python.org/pypi/pyinotify/">pyinotify</a>, kernel signals will be used to
autoreload the server (rather than polling file modification timestamps each
second). This offers better scaling to large projects, reduction in response
time to code modification, more robust change detection, and battery usage
reduction.</p>
<div class="versionadded">
<span class="title">New in Django 1.7:</span> <p><code class="docutils literal"><span class="pre">pyinotify</span></code> support was added.</p>
</div>
<p>When you start the server, and each time you change Python code while the
server is running, the system check framework will check your entire Django
project for some common errors (see the <a class="reference internal" href="#django-admin-check"><code class="xref std std-djadmin docutils literal"><span class="pre">check</span></code></a> command). If any
errors are found, they will be printed to standard output.</p>
<p>You can run as many concurrent servers as you want, as long as they&#8217;re on
separate ports. Just execute <code class="docutils literal"><span class="pre">django-admin</span> <span class="pre">runserver</span></code> more than once.</p>
<p>Note that the default IP address, <code class="docutils literal"><span class="pre">127.0.0.1</span></code>, is not accessible from other
machines on your network. To make your development server viewable to other
machines on the network, use its own IP address (e.g. <code class="docutils literal"><span class="pre">192.168.2.1</span></code>) or
<code class="docutils literal"><span class="pre">0.0.0.0</span></code> or <code class="docutils literal"><span class="pre">::</span></code> (with IPv6 enabled).</p>
<p>You can provide an IPv6 address surrounded by brackets
(e.g. <code class="docutils literal"><span class="pre">[200a::1]:8000</span></code>). This will automatically enable IPv6 support.</p>
<p>A hostname containing ASCII-only characters can also be used.</p>
<p>If the <a class="reference internal" href="contrib/staticfiles.html"><span class="doc">staticfiles</span></a> contrib app is enabled
(default in new projects) the <a class="reference internal" href="#django-admin-runserver"><code class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></code></a> command will be overridden
with its own <a class="reference internal" href="contrib/staticfiles.html#staticfiles-runserver"><span class="std std-ref">runserver</span></a> command.</p>
<p>If <a class="reference internal" href="#django-admin-migrate"><code class="xref std std-djadmin docutils literal"><span class="pre">migrate</span></code></a> was not previously executed, the table that stores the
history of migrations is created at first run of <code class="docutils literal"><span class="pre">runserver</span></code>.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---noreload">
<code class="descname">--noreload</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---noreload" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--noreload</span></code> option to disable the use of the auto-reloader. This
means any Python code changes you make while the server is running will <em>not</em>
take effect if the particular Python modules have already been loaded into
memory.</p>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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">noreload</span>
</pre></div>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---nothreading">
<code class="descname">--nothreading</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---nothreading" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The development server is multithreaded by default. Use the <code class="docutils literal"><span class="pre">--nothreading</span></code>
option to disable the use of threading in the development server.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---ipv6">
<code class="descname">--ipv6</code><code class="descclassname">, -6</code><a class="headerlink" href="#django-admin-option---ipv6" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--ipv6</span></code> (or shorter <code class="docutils literal"><span class="pre">-6</span></code>) option to tell Django to use IPv6 for
the development server. This changes the default IP address from
<code class="docutils literal"><span class="pre">127.0.0.1</span></code> to <code class="docutils literal"><span class="pre">::1</span></code>.</p>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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">ipv6</span>
</pre></div>
</div>
<div class="section" id="s-examples-of-using-different-ports-and-addresses">
<span id="examples-of-using-different-ports-and-addresses"></span><h4>Examples of using different ports and addresses<a class="headerlink" href="#examples-of-using-different-ports-and-addresses" title="Permalink to this headline">¶</a></h4>
<p>Port 8000 on IP address <code class="docutils literal"><span class="pre">127.0.0.1</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">django</span><span class="o">-</span><span class="n">admin</span> <span class="n">runserver</span>
</pre></div>
</div>
<p>Port 8000 on IP address <code class="docutils literal"><span class="pre">1.2.3.4</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">django</span><span class="o">-</span><span class="n">admin</span> <span class="n">runserver</span> <span class="mf">1.2</span><span class="o">.</span><span class="mf">3.4</span><span class="p">:</span><span class="mi">8000</span>
</pre></div>
</div>
<p>Port 7000 on IP address <code class="docutils literal"><span class="pre">127.0.0.1</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">django</span><span class="o">-</span><span class="n">admin</span> <span class="n">runserver</span> <span class="mi">7000</span>
</pre></div>
</div>
<p>Port 7000 on IP address <code class="docutils literal"><span class="pre">1.2.3.4</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">django</span><span class="o">-</span><span class="n">admin</span> <span class="n">runserver</span> <span class="mf">1.2</span><span class="o">.</span><span class="mf">3.4</span><span class="p">:</span><span class="mi">7000</span>
</pre></div>
</div>
<p>Port 8000 on IPv6 address <code class="docutils literal"><span class="pre">::1</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Port 7000 on IPv6 address <code class="docutils literal"><span class="pre">::1</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Port 7000 on IPv6 address <code class="docutils literal"><span class="pre">2001:0db8:1234:5678::9</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Port 8000 on IPv4 address of host <code class="docutils literal"><span class="pre">localhost</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Port 8000 on IPv6 address of host <code class="docutils literal"><span class="pre">localhost</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
</div>
<div class="section" id="s-serving-static-files-with-the-development-server">
<span id="serving-static-files-with-the-development-server"></span><h4>Serving static files with the development server<a class="headerlink" href="#serving-static-files-with-the-development-server" title="Permalink to this headline">¶</a></h4>
<p>By default, the development server doesn&#8217;t serve any static files for your site
(such as CSS files, images, things under <a class="reference internal" href="settings.html#std:setting-MEDIA_URL"><code class="xref std std-setting docutils literal"><span class="pre">MEDIA_URL</span></code></a> and so forth). If
you want to configure Django to serve static media, read
<a class="reference internal" href="../howto/static-files/index.html"><span class="doc">Managing static files (e.g. images, JavaScript, CSS)</span></a>.</p>
</div>
</div>
<div class="section" id="s-shell">
<span id="shell"></span><h3>shell<a class="headerlink" href="#shell" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-shell">
<code class="descname">django-admin shell</code><a class="headerlink" href="#django-admin-shell" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Starts the Python interactive interpreter.</p>
<p>Django will use <a class="reference external" href="http://ipython.scipy.org/">IPython</a> or <a class="reference external" href="http://bpython-interpreter.org/">bpython</a> if either is installed. If you have a
rich shell installed but want to force use of the &#8220;plain&#8221; Python interpreter,
use the <code class="docutils literal"><span class="pre">--plain</span></code> option, like so:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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">plain</span>
</pre></div>
</div>
<p>If you would like to specify either IPython or bpython as your interpreter if
you have both installed you can specify an alternative interpreter interface
with the <code class="docutils literal"><span class="pre">-i</span></code> or <code class="docutils literal"><span class="pre">--interface</span></code> options like so:</p>
<p>IPython:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
<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">interface</span> <span class="n">ipython</span>
</pre></div>
</div>
<p>bpython:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
<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">interface</span> <span class="n">bpython</span>
</pre></div>
</div>
<p>When the &#8220;plain&#8221; Python interactive interpreter starts (be it because
<code class="docutils literal"><span class="pre">--plain</span></code> was specified or because no other interactive interface is
available) it reads the script pointed to by the <span class="target" id="index-3"></span><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONSTARTUP</span></code>
environment variable and the <code class="docutils literal"><span class="pre">~/.pythonrc.py</span></code> script. If you don&#8217;t wish this
behavior you can use the <code class="docutils literal"><span class="pre">--no-startup</span></code> option. e.g.:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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">plain</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">startup</span>
</pre></div>
</div>
</div>
<div class="section" id="s-showmigrations-app-label-app-label">
<span id="showmigrations-app-label-app-label"></span><h3>showmigrations [&lt;app_label&gt; [&lt;app_label&gt;]]<a class="headerlink" href="#showmigrations-app-label-app-label" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-showmigrations">
<code class="descname">django-admin showmigrations</code><a class="headerlink" href="#django-admin-showmigrations" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>Shows all migrations in a project.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---list">
<code class="descname">--list</code><code class="descclassname">, -l</code><a class="headerlink" href="#django-admin-option---list" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <code class="docutils literal"><span class="pre">--list</span></code> option lists all of the apps Django knows about, the
migrations available for each app, and whether or not each migration is
applied (marked by an <code class="docutils literal"><span class="pre">[X]</span></code> next to the migration name).</p>
<p>Apps without migrations are also listed, but have <code class="docutils literal"><span class="pre">(no</span> <span class="pre">migrations)</span></code> printed
under them.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---plan">
<code class="descname">--plan</code><code class="descclassname">, -p</code><a class="headerlink" href="#django-admin-option---plan" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <code class="docutils literal"><span class="pre">--plan</span></code> option shows the migration plan Django will follow to apply
migrations. Any supplied app labels are ignored because the plan might go
beyond those apps. Same as <code class="docutils literal"><span class="pre">--list</span></code>, applied migrations are marked by an
<code class="docutils literal"><span class="pre">[X]</span></code>. For a verbosity of 2 and above, all dependencies of a migration will
also be shown.</p>
</div>
<div class="section" id="s-sql-app-label-app-label">
<span id="sql-app-label-app-label"></span><h3>sql &lt;app_label app_label ...&gt;<a class="headerlink" href="#sql-app-label-app-label" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sql">
<code class="descname">django-admin sql</code><a class="headerlink" href="#django-admin-sql" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Prints the CREATE TABLE SQL statements for the given app name(s).</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqlall-app-label-app-label">
<span id="sqlall-app-label-app-label"></span><h3>sqlall &lt;app_label app_label ...&gt;<a class="headerlink" href="#sqlall-app-label-app-label" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlall">
<code class="descname">django-admin sqlall</code><a class="headerlink" href="#django-admin-sqlall" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Prints the CREATE TABLE and initial-data SQL statements for the given app name(s).</p>
<p>Refer to the description of <a class="reference internal" href="#django-admin-sqlcustom"><code class="xref std std-djadmin docutils literal"><span class="pre">sqlcustom</span></code></a> for an explanation of how to
specify initial data.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database for
which to print the SQL.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.7:</span> <p>The <code class="docutils literal"><span class="pre">sql*</span></code> management commands now respect the <code class="docutils literal"><span class="pre">allow_migrate()</span></code> method
of <a class="reference internal" href="settings.html#std:setting-DATABASE_ROUTERS"><code class="xref std std-setting docutils literal"><span class="pre">DATABASE_ROUTERS</span></code></a>. If you have models synced to non-default
databases, use the <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> flag to get SQL for those
models (previously they would always be included in the output).</p>
</div>
</div>
<div class="section" id="s-sqlclear-app-label-app-label">
<span id="sqlclear-app-label-app-label"></span><h3>sqlclear &lt;app_label app_label ...&gt;<a class="headerlink" href="#sqlclear-app-label-app-label" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlclear">
<code class="descname">django-admin sqlclear</code><a class="headerlink" href="#django-admin-sqlclear" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Prints the DROP TABLE SQL statements for the given app name(s).</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqlcustom-app-label-app-label">
<span id="sqlcustom-app-label-app-label"></span><h3>sqlcustom &lt;app_label app_label ...&gt;<a class="headerlink" href="#sqlcustom-app-label-app-label" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlcustom">
<code class="descname">django-admin sqlcustom</code><a class="headerlink" href="#django-admin-sqlcustom" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Prints the custom SQL statements for the given app name(s).</p>
<p>For each model in each specified app, this command looks for the file
<code class="docutils literal"><span class="pre">&lt;app_label&gt;/sql/&lt;modelname&gt;.sql</span></code>, where <code class="docutils literal"><span class="pre">&lt;app_label&gt;</span></code> is the given app
name and <code class="docutils literal"><span class="pre">&lt;modelname&gt;</span></code> is the model&#8217;s name in lowercase. For example, if you
have an app <code class="docutils literal"><span class="pre">news</span></code> that includes a <code class="docutils literal"><span class="pre">Story</span></code> model, <code class="docutils literal"><span class="pre">sqlcustom</span></code> will
attempt to read a file <code class="docutils literal"><span class="pre">news/sql/story.sql</span></code> and append it to the output of
this command.</p>
<p>Each of the SQL files, if given, is expected to contain valid SQL. The SQL
files are piped directly into the database after all of the models&#8217;
table-creation statements have been executed. Use this SQL hook to make any
table modifications, or insert any SQL functions into the database.</p>
<p>Note that the order in which the SQL files are processed is undefined.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqldropindexes-app-label-app-label">
<span id="sqldropindexes-app-label-app-label"></span><h3>sqldropindexes &lt;app_label app_label ...&gt;<a class="headerlink" href="#sqldropindexes-app-label-app-label" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqldropindexes">
<code class="descname">django-admin sqldropindexes</code><a class="headerlink" href="#django-admin-sqldropindexes" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Prints the DROP INDEX SQL statements for the given app name(s).</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqlflush">
<span id="sqlflush"></span><h3>sqlflush<a class="headerlink" href="#sqlflush" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlflush">
<code class="descname">django-admin sqlflush</code><a class="headerlink" href="#django-admin-sqlflush" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<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"><span class="pre">flush</span></code></a>
command.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqlindexes-app-label-app-label">
<span id="sqlindexes-app-label-app-label"></span><h3>sqlindexes &lt;app_label app_label ...&gt;<a class="headerlink" href="#sqlindexes-app-label-app-label" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlindexes">
<code class="descname">django-admin sqlindexes</code><a class="headerlink" href="#django-admin-sqlindexes" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Prints the CREATE INDEX SQL statements for the given app name(s).</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqlmigrate-app-label-migrationname">
<span id="sqlmigrate-app-label-migrationname"></span><h3>sqlmigrate &lt;app_label&gt; &lt;migrationname&gt;<a class="headerlink" href="#sqlmigrate-app-label-migrationname" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlmigrate">
<code class="descname">django-admin sqlmigrate</code><a class="headerlink" href="#django-admin-sqlmigrate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Prints the SQL for the named migration. This requires an active database
connection, which it will use to resolve constraint names; this means you must
generate the SQL against a copy of the database you wish to later apply it on.</p>
<p>Note that <code class="docutils literal"><span class="pre">sqlmigrate</span></code> doesn&#8217;t colorize its output.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database for
which to generate the SQL.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---backwards">
<code class="descname">--backwards</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---backwards" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>By default, the SQL created is for running the migration in the forwards
direction. Pass <code class="docutils literal"><span class="pre">--backwards</span></code> to generate the SQL for
unapplying the migration instead.</p>
</div>
<div class="section" id="s-sqlsequencereset-app-label-app-label">
<span id="sqlsequencereset-app-label-app-label"></span><h3>sqlsequencereset &lt;app_label app_label ...&gt;<a class="headerlink" href="#sqlsequencereset-app-label-app-label" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlsequencereset">
<code class="descname">django-admin sqlsequencereset</code><a class="headerlink" href="#django-admin-sqlsequencereset" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Prints the SQL statements for resetting sequences for the given app name(s).</p>
<p>Sequences are indexes used by some database engines to track the next available
number for automatically incremented fields.</p>
<p>Use this command to generate SQL which will fix cases where a sequence is out
of sync with its automatically incremented field data.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><code class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></code></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-squashmigrations-app-label-migration-name">
<span id="squashmigrations-app-label-migration-name"></span><h3>squashmigrations &lt;app_label&gt; &lt;migration_name&gt;<a class="headerlink" href="#squashmigrations-app-label-migration-name" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-squashmigrations">
<code class="descname">django-admin squashmigrations</code><a class="headerlink" href="#django-admin-squashmigrations" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Squashes the migrations for <code class="docutils literal"><span class="pre">app_label</span></code> up to and including <code class="docutils literal"><span class="pre">migration_name</span></code>
down into fewer migrations, if possible. The resulting squashed migrations
can live alongside the unsquashed ones safely. For more information,
please read <a class="reference internal" href="../topics/migrations.html#migration-squashing"><span class="std std-ref">Squashing migrations</span></a>.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---no-optimize">
<code class="descname">--no-optimize</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---no-optimize" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>By default, Django will try to optimize the operations in your migrations
to reduce the size of the resulting file. Pass <code class="docutils literal"><span class="pre">--no-optimize</span></code> if this
process is failing for you or creating incorrect migrations, though please
also file a Django bug report about the behavior, as optimization is meant
to be safe.</p>
</div>
<div class="section" id="s-startapp-app-label-destination">
<span id="startapp-app-label-destination"></span><h3>startapp &lt;app_label&gt; [destination]<a class="headerlink" href="#startapp-app-label-destination" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-startapp">
<code class="descname">django-admin startapp</code><a class="headerlink" href="#django-admin-startapp" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Creates a Django app directory structure for the given app name in the current
directory or the given destination.</p>
<p>By default the directory created contains a <code class="docutils literal"><span class="pre">models.py</span></code> file and other app
template files. (See the <a class="reference external" href="https://github.com/django/django/tree/master/django/conf/app_template/">source</a> for more details.) If only the app
name is given, the app directory will be created in the current working
directory.</p>
<p>If the optional destination is provided, Django will use that existing
directory rather than creating a new one. You can use &#8216;.&#8217; to denote the current
working directory.</p>
<p>For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<span class="target" id="custom-app-and-project-templates"></span><dl class="django-admin-option">
<dt id="django-admin-option---template">
<code class="descname">--template</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---template" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>With the <code class="docutils literal"><span class="pre">--template</span></code> option, you can use a custom app template by providing
either the path to a directory with the app template file, or a path to a
compressed file (<code class="docutils literal"><span class="pre">.tar.gz</span></code>, <code class="docutils literal"><span class="pre">.tar.bz2</span></code>, <code class="docutils literal"><span class="pre">.tgz</span></code>, <code class="docutils literal"><span class="pre">.tbz</span></code>, <code class="docutils literal"><span class="pre">.zip</span></code>)
containing the app template files.</p>
<p>For example, this would look for an app template in the given directory when
creating the <code class="docutils literal"><span class="pre">myapp</span></code> app:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Django will also accept URLs (<code class="docutils literal"><span class="pre">http</span></code>, <code class="docutils literal"><span class="pre">https</span></code>, <code class="docutils literal"><span class="pre">ftp</span></code>) to compressed
archives with the app template files, downloading and extracting them on the
fly.</p>
<p>For example, taking advantage of Github&#8217;s feature to expose repositories as
zip files, you can use a URL like:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>When Django copies the app template files, it also renders certain files
through the template engine: the files whose extensions match the
<code class="docutils literal"><span class="pre">--extension</span></code> option (<code class="docutils literal"><span class="pre">py</span></code> by default) and the files whose names are passed
with the <code class="docutils literal"><span class="pre">--name</span></code> option. The <a class="reference internal" href="templates/api.html#django.template.Context" title="django.template.Context"><code class="xref py py-class docutils literal"><span class="pre">template</span> <span class="pre">context</span></code></a> used is:</p>
<ul class="simple">
<li>Any option passed to the <code class="docutils literal"><span class="pre">startapp</span></code> command (among the command&#8217;s supported
options)</li>
<li><code class="docutils literal"><span class="pre">app_name</span></code> &#8211; the app name as passed to the command</li>
<li><code class="docutils literal"><span class="pre">app_directory</span></code> &#8211; the full path of the newly created app</li>
<li><code class="docutils literal"><span class="pre">docs_version</span></code> &#8211; the version of the documentation: <code class="docutils literal"><span class="pre">'dev'</span></code> or <code class="docutils literal"><span class="pre">'1.x'</span></code></li>
</ul>
<div class="admonition warning" id="render-warning">
<p class="first admonition-title">Warning</p>
<p>When the app template files are rendered with the Django template
engine (by default all <code class="docutils literal"><span class="pre">*.py</span></code> files), Django will also replace all
stray template variables contained. For example, if one of the Python files
contains a docstring explaining a particular feature related
to template rendering, it might result in an incorrect example.</p>
<p class="last">To work around this problem, you can use the <a class="reference internal" href="templates/builtins.html#std:templatetag-templatetag"><code class="xref std std-ttag docutils literal"><span class="pre">templatetag</span></code></a>
templatetag to &#8220;escape&#8221; the various parts of the template syntax.</p>
</div>
</div>
<div class="section" id="s-startproject-projectname-destination">
<span id="startproject-projectname-destination"></span><h3>startproject &lt;projectname&gt; [destination]<a class="headerlink" href="#startproject-projectname-destination" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-startproject">
<code class="descname">django-admin startproject</code><a class="headerlink" href="#django-admin-startproject" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Creates a Django project directory structure for the given project name in
the current directory or the given destination.</p>
<p>By default, the new directory contains <code class="docutils literal"><span class="pre">manage.py</span></code> and a project package
(containing a <code class="docutils literal"><span class="pre">settings.py</span></code> and other files). See the <a class="reference external" href="https://github.com/django/django/tree/master/django/conf/project_template/">template source</a> for
details.</p>
<p>If only the project name is given, both the project directory and project
package will be named <code class="docutils literal"><span class="pre">&lt;projectname&gt;</span></code> and the project directory
will be created in the current working directory.</p>
<p>If the optional destination is provided, Django will use that existing
directory as the project directory, and create <code class="docutils literal"><span class="pre">manage.py</span></code> and the project
package within it. Use &#8216;.&#8217; to denote the current working directory.</p>
<p>For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>As with the <a class="reference internal" href="#django-admin-startapp"><code class="xref std std-djadmin docutils literal"><span class="pre">startapp</span></code></a> command, the <code class="docutils literal"><span class="pre">--template</span></code> option lets you
specify a directory, file path or URL of a custom project template. See the
<a class="reference internal" href="#django-admin-startapp"><code class="xref std std-djadmin docutils literal"><span class="pre">startapp</span></code></a> documentation for details of supported project template
formats.</p>
<p>For example, this would look for a project template in the given directory
when creating the <code class="docutils literal"><span class="pre">myproject</span></code> project:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">django</span><span class="o">-</span><span class="n">admin</span> <span class="n">startproject</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_project_template</span> <span class="n">myproject</span>
</pre></div>
</div>
<p>Django will also accept URLs (<code class="docutils literal"><span class="pre">http</span></code>, <code class="docutils literal"><span class="pre">https</span></code>, <code class="docutils literal"><span class="pre">ftp</span></code>) to compressed
archives with the project template files, downloading and extracting them on the
fly.</p>
<p>For example, taking advantage of Github&#8217;s feature to expose repositories as
zip files, you can use a URL like:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">django</span><span class="o">-</span><span class="n">admin</span> <span class="n">startproject</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">project</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">myproject</span>
</pre></div>
</div>
<p>When Django copies the project template files, it also renders certain files
through the template engine: the files whose extensions match the
<code class="docutils literal"><span class="pre">--extension</span></code> option (<code class="docutils literal"><span class="pre">py</span></code> by default) and the files whose names are passed
with the <code class="docutils literal"><span class="pre">--name</span></code> option. The <a class="reference internal" href="templates/api.html#django.template.Context" title="django.template.Context"><code class="xref py py-class docutils literal"><span class="pre">template</span> <span class="pre">context</span></code></a> used is:</p>
<ul class="simple">
<li>Any option passed to the <code class="docutils literal"><span class="pre">startproject</span></code> command (among the command&#8217;s
supported options)</li>
<li><code class="docutils literal"><span class="pre">project_name</span></code> &#8211; the project name as passed to the command</li>
<li><code class="docutils literal"><span class="pre">project_directory</span></code> &#8211; the full path of the newly created project</li>
<li><code class="docutils literal"><span class="pre">secret_key</span></code> &#8211; a random key for the <a class="reference internal" href="settings.html#std:setting-SECRET_KEY"><code class="xref std std-setting docutils literal"><span class="pre">SECRET_KEY</span></code></a> setting</li>
<li><code class="docutils literal"><span class="pre">docs_version</span></code> &#8211; the version of the documentation: <code class="docutils literal"><span class="pre">'dev'</span></code> or <code class="docutils literal"><span class="pre">'1.x'</span></code></li>
</ul>
<p>Please also see the <a class="reference internal" href="#render-warning"><span class="std std-ref">rendering warning</span></a> as mentioned
for <a class="reference internal" href="#django-admin-startapp"><code class="xref std std-djadmin docutils literal"><span class="pre">startapp</span></code></a>.</p>
</div>
<div class="section" id="s-syncdb">
<span id="syncdb"></span><h3>syncdb<a class="headerlink" href="#syncdb" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-syncdb">
<code class="descname">django-admin syncdb</code><a class="headerlink" href="#django-admin-syncdb" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 1.7: </span>This command has been deprecated in favor of the <a class="reference internal" href="#django-admin-migrate"><code class="xref std std-djadmin docutils literal"><span class="pre">migrate</span></code></a>
command, which performs both the old behavior as well as executing
migrations.</p>
</div>
<p>Alias for <a class="reference internal" href="#django-admin-migrate"><code class="xref std std-djadmin docutils literal"><span class="pre">migrate</span></code></a>, except that it also prompts you to create a
superuser if one doesn&#8217;t exist (assuming you are using <code class="docutils literal"><span class="pre">django.contrib.auth</span></code>).</p>
</div>
<div class="section" id="s-test-app-or-test-identifier">
<span id="test-app-or-test-identifier"></span><h3>test &lt;app or test identifier&gt;<a class="headerlink" href="#test-app-or-test-identifier" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-test">
<code class="descname">django-admin test</code><a class="headerlink" href="#django-admin-test" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Runs tests for all installed models. See <a class="reference internal" href="../topics/testing/index.html"><span class="doc">Testing in Django</span></a> for more
information.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---failfast">
<code class="descname">--failfast</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---failfast" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <code class="docutils literal"><span class="pre">--failfast</span></code> option can be used to stop running tests and report the
failure immediately after a test fails.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---testrunner">
<code class="descname">--testrunner</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---testrunner" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <code class="docutils literal"><span class="pre">--testrunner</span></code> option can be used to control the test runner class that
is used to execute tests. If this value is provided, it overrides the value
provided by the <a class="reference internal" href="settings.html#std:setting-TEST_RUNNER"><code class="xref std std-setting docutils literal"><span class="pre">TEST_RUNNER</span></code></a> setting.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---liveserver">
<code class="descname">--liveserver</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---liveserver" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <code class="docutils literal"><span class="pre">--liveserver</span></code> option can be used to override the default address where
the live server (used with <a class="reference internal" href="../topics/testing/tools.html#django.test.LiveServerTestCase" title="django.test.LiveServerTestCase"><code class="xref py py-class docutils literal"><span class="pre">LiveServerTestCase</span></code></a>) is
expected to run from. The default value is <code class="docutils literal"><span class="pre">localhost:8081</span></code>.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---keepdb">
<code class="descname">--keepdb</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---keepdb" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>The <code class="docutils literal"><span class="pre">--keepdb</span></code> option can be used to preserve the test database between test
runs. This has the advantage of skipping both the create and destroy actions
which can greatly decrease the time to run tests, especially those in a large
test suite. If the test database does not exist, it will be created on the first
run and then preserved for each subsequent run. Any unapplied migrations will also
be applied to the test database before running the test suite.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---reverse">
<code class="descname">--reverse</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---reverse" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>The <code class="docutils literal"><span class="pre">--reverse</span></code> option can be used to sort test cases in the opposite order.
This may help in debugging the side effects of tests that aren&#8217;t properly
isolated. <a class="reference internal" href="../topics/testing/overview.html#order-of-tests"><span class="std std-ref">Grouping by test class</span></a> is preserved when using
this option.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---debug-sql">
<code class="descname">--debug-sql</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---debug-sql" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>The <code class="docutils literal"><span class="pre">--debug-sql</span></code> option can be used to enable <a class="reference internal" href="../topics/logging.html#django-db-logger"><span class="std std-ref">SQL logging</span></a> for failing tests. If <a class="reference internal" href="#django-admin-option---verbosity"><code class="xref std std-djadminopt docutils literal"><span class="pre">--verbosity</span></code></a> is <code class="docutils literal"><span class="pre">2</span></code>,
then queries in passing tests are also output.</p>
</div>
<div class="section" id="s-testserver-fixture-fixture">
<span id="testserver-fixture-fixture"></span><h3>testserver &lt;fixture fixture ...&gt;<a class="headerlink" href="#testserver-fixture-fixture" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-testserver">
<code class="descname">django-admin testserver</code><a class="headerlink" href="#django-admin-testserver" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Runs a Django development server (as in <a class="reference internal" href="#django-admin-runserver"><code class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></code></a>) using data from
the given fixture(s).</p>
<p>For example, this command:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>...would perform the following steps:</p>
<ol class="arabic simple">
<li>Create a test database, as described in <a class="reference internal" href="../topics/testing/overview.html#the-test-database"><span class="std std-ref">The test database</span></a>.</li>
<li>Populate the test database with fixture data from the given fixtures.
(For more on fixtures, see the documentation for <a class="reference internal" href="#django-admin-loaddata"><code class="xref std std-djadmin docutils literal"><span class="pre">loaddata</span></code></a> above.)</li>
<li>Runs the Django development server (as in <a class="reference internal" href="#django-admin-runserver"><code class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></code></a>), pointed at
this newly created test database instead of your production database.</li>
</ol>
<p>This is useful in a number of ways:</p>
<ul class="simple">
<li>When you&#8217;re writing <a class="reference internal" href="../topics/testing/overview.html"><span class="doc">unit tests</span></a> of how your views
act with certain fixture data, you can use <code class="docutils literal"><span class="pre">testserver</span></code> to interact with
the views in a Web browser, manually.</li>
<li>Let&#8217;s say you&#8217;re developing your Django application and have a &#8220;pristine&#8221;
copy of a database that you&#8217;d like to interact with. You can dump your
database to a fixture (using the <a class="reference internal" href="#django-admin-dumpdata"><code class="xref std std-djadmin docutils literal"><span class="pre">dumpdata</span></code></a> command, explained
above), then use <code class="docutils literal"><span class="pre">testserver</span></code> to run your Web application with that data.
With this arrangement, you have the flexibility of messing up your data
in any way, knowing that whatever data changes you&#8217;re making are only
being made to a test database.</li>
</ul>
<p>Note that this server does <em>not</em> automatically detect changes to your Python
source code (as <a class="reference internal" href="#django-admin-runserver"><code class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></code></a> does). It does, however, detect changes to
templates.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---addrport">
<code class="descname">--addrport</code><code class="descclassname"> [port number or ipaddr:port]</code><a class="headerlink" href="#django-admin-option---addrport" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use <code class="docutils literal"><span class="pre">--addrport</span></code> to specify a different port, or IP address and port, from
the default of <code class="docutils literal"><span class="pre">127.0.0.1:8000</span></code>. This value follows exactly the same format and
serves exactly the same function as the argument to the <a class="reference internal" href="#django-admin-runserver"><code class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></code></a>
command.</p>
<p>Examples:</p>
<p>To run the test server on port 7000 with <code class="docutils literal"><span class="pre">fixture1</span></code> and <code class="docutils literal"><span class="pre">fixture2</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
<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>
</pre></div>
</div>
<p>(The above statements are equivalent. We include both of them to demonstrate
that it doesn&#8217;t matter whether the options come before or after the fixture
arguments.)</p>
<p>To run on 1.2.3.4:7000 with a <code class="docutils literal"><span class="pre">test</span></code> fixture:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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</span><span class="o">.</span><span class="mf">3.4</span><span class="p">:</span><span class="mi">7000</span> <span class="n">test</span>
</pre></div>
</div>
<p>The <a class="reference internal" href="#django-admin-option---noinput"><code class="xref std std-djadminopt docutils literal"><span class="pre">--noinput</span></code></a> option may be provided to suppress all user
prompts.</p>
</div>
<div class="section" id="s-validate">
<span id="validate"></span><h3>validate<a class="headerlink" href="#validate" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-validate">
<code class="descname">django-admin validate</code><a class="headerlink" href="#django-admin-validate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 1.7: </span>Replaced by the <a class="reference internal" href="#django-admin-check"><code class="xref std std-djadmin docutils literal"><span class="pre">check</span></code></a> command.</p>
</div>
<p>Validates all installed models (according to the <a class="reference internal" href="settings.html#std:setting-INSTALLED_APPS"><code class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></code></a>
setting) and prints validation errors to standard output.</p>
</div>
</div>
<div class="section" id="s-commands-provided-by-applications">
<span id="commands-provided-by-applications"></span><h2>Commands provided by applications<a class="headerlink" href="#commands-provided-by-applications" title="Permalink to this headline">¶</a></h2>
<p>Some commands are only available when the <code class="docutils literal"><span class="pre">django.contrib</span></code> application that
<a class="reference internal" href="../howto/custom-management-commands.html"><span class="doc">implements</span></a> them has been
<a class="reference internal" href="settings.html#std:setting-INSTALLED_APPS"><code class="xref std std-setting docutils literal"><span class="pre">enabled</span></code></a>. This section describes them grouped by
their application.</p>
<div class="section" id="s-django-contrib-auth">
<span id="django-contrib-auth"></span><h3><code class="docutils literal"><span class="pre">django.contrib.auth</span></code><a class="headerlink" href="#django-contrib-auth" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-changepassword">
<span id="changepassword"></span><h4>changepassword<a class="headerlink" href="#changepassword" title="Permalink to this headline">¶</a></h4>
<dl class="django-admin">
<dt id="django-admin-changepassword">
<code class="descname">django-admin changepassword</code><a class="headerlink" href="#django-admin-changepassword" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>This command is only available if Django&#8217;s <a class="reference internal" href="../topics/auth/index.html"><span class="doc">authentication system</span></a> (<code class="docutils literal"><span class="pre">django.contrib.auth</span></code>) is installed.</p>
<p>Allows changing a user&#8217;s password. It prompts you to enter a new password twice
for the given user. If the entries are identical, this immediately becomes the
new password. If you do not supply a user, the command will attempt to change
the password whose username matches the current user.</p>
<p>Use the <code class="docutils literal"><span class="pre">--database</span></code> option to specify the database to query for the user. If
it&#8217;s not supplied, Django will use the <code class="docutils literal"><span class="pre">default</span></code> database.</p>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">django</span><span class="o">-</span><span class="n">admin</span> <span class="n">changepassword</span> <span class="n">ringo</span>
</pre></div>
</div>
</div>
<div class="section" id="s-createsuperuser">
<span id="createsuperuser"></span><h4>createsuperuser<a class="headerlink" href="#createsuperuser" title="Permalink to this headline">¶</a></h4>
<dl class="django-admin">
<dt id="django-admin-createsuperuser">
<code class="descname">django-admin createsuperuser</code><a class="headerlink" href="#django-admin-createsuperuser" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>This command is only available if Django&#8217;s <a class="reference internal" href="../topics/auth/index.html"><span class="doc">authentication system</span></a> (<code class="docutils literal"><span class="pre">django.contrib.auth</span></code>) is installed.</p>
<p>Creates a superuser account (a user who has all permissions). This is
useful if you need to create an initial superuser account or if you need to
programmatically generate superuser accounts for your site(s).</p>
<p>When run interactively, this command will prompt for a password for
the new superuser account. When run non-interactively, no password
will be set, and the superuser account will not be able to log in until
a password has been manually set for it.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---username">
<code class="descname">--username</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---username" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="django-admin-option">
<dt id="django-admin-option---email">
<code class="descname">--email</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---email" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The username and email address for the new account can be supplied by
using the <code class="docutils literal"><span class="pre">--username</span></code> and <code class="docutils literal"><span class="pre">--email</span></code> arguments on the command
line. If either of those is not supplied, <code class="docutils literal"><span class="pre">createsuperuser</span></code> will prompt for
it when running interactively.</p>
<p>Use the <code class="docutils literal"><span class="pre">--database</span></code> option to specify the database into which the superuser
object will be saved.</p>
<div class="versionadded">
<span class="title">New in Django 1.8.</span> </div>
<p>You can subclass the management command and override <code class="docutils literal"><span class="pre">get_input_data()</span></code> if you
want to customize data input and validation. Consult the source code for
details on the existing implementation and the method&#8217;s parameters. For example,
it could be useful if you have a <code class="docutils literal"><span class="pre">ForeignKey</span></code> in
<a class="reference internal" href="../topics/auth/customizing.html#django.contrib.auth.models.CustomUser.REQUIRED_FIELDS" title="django.contrib.auth.models.CustomUser.REQUIRED_FIELDS"><code class="xref py py-attr docutils literal"><span class="pre">REQUIRED_FIELDS</span></code></a> and want to
allow creating an instance instead of entering the primary key of an existing
instance.</p>
</div>
</div>
<div class="section" id="s-django-contrib-gis">
<span id="django-contrib-gis"></span><h3><code class="docutils literal"><span class="pre">django.contrib.gis</span></code><a class="headerlink" href="#django-contrib-gis" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-ogrinspect">
<span id="ogrinspect"></span><h4>ogrinspect<a class="headerlink" href="#ogrinspect" title="Permalink to this headline">¶</a></h4>
<p>This command is only available if <a class="reference internal" href="contrib/gis/index.html"><span class="doc">GeoDjango</span></a>
(<code class="docutils literal"><span class="pre">django.contrib.gis</span></code>) is installed.</p>
<p>Please refer to its <a class="reference internal" href="contrib/gis/commands.html#django-admin-ogrinspect"><code class="xref std std-djadmin docutils literal"><span class="pre">description</span></code></a> in the GeoDjango
documentation.</p>
</div>
</div>
<div class="section" id="s-django-contrib-sessions">
<span id="django-contrib-sessions"></span><h3><code class="docutils literal"><span class="pre">django.contrib.sessions</span></code><a class="headerlink" href="#django-contrib-sessions" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-clearsessions">
<span id="clearsessions"></span><h4>clearsessions<a class="headerlink" href="#clearsessions" title="Permalink to this headline">¶</a></h4>
<dl class="django-admin">
<dt id="django-admin-clearsessions">
<code class="descname">django-admin clearsessions</code><a class="headerlink" href="#django-admin-clearsessions" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Can be run as a cron job or directly to clean out expired sessions.</p>
</div>
</div>
<div class="section" id="s-django-contrib-sitemaps">
<span id="django-contrib-sitemaps"></span><h3><code class="docutils literal"><span class="pre">django.contrib.sitemaps</span></code><a class="headerlink" href="#django-contrib-sitemaps" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-ping-google">
<span id="ping-google"></span><h4>ping_google<a class="headerlink" href="#ping-google" title="Permalink to this headline">¶</a></h4>
<p>This command is only available if the <a class="reference internal" href="contrib/sitemaps.html"><span class="doc">Sitemaps framework</span></a> (<code class="docutils literal"><span class="pre">django.contrib.sitemaps</span></code>) is installed.</p>
<p>Please refer to its <a class="reference internal" href="contrib/sitemaps.html#django-admin-ping_google"><code class="xref std std-djadmin docutils literal"><span class="pre">description</span></code></a> in the Sitemaps
documentation.</p>
</div>
</div>
<div class="section" id="s-django-contrib-staticfiles">
<span id="django-contrib-staticfiles"></span><h3><code class="docutils literal"><span class="pre">django.contrib.staticfiles</span></code><a class="headerlink" href="#django-contrib-staticfiles" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-collectstatic">
<span id="collectstatic"></span><h4>collectstatic<a class="headerlink" href="#collectstatic" title="Permalink to this headline">¶</a></h4>
<p>This command is only available if the <a class="reference internal" href="../howto/static-files/index.html"><span class="doc">static files application</span></a> (<code class="docutils literal"><span class="pre">django.contrib.staticfiles</span></code>) is installed.</p>
<p>Please refer to its <a class="reference internal" href="contrib/staticfiles.html#django-admin-collectstatic"><code class="xref std std-djadmin docutils literal"><span class="pre">description</span></code></a> in the
<a class="reference internal" href="contrib/staticfiles.html"><span class="doc">staticfiles</span></a> documentation.</p>
</div>
<div class="section" id="s-findstatic">
<span id="findstatic"></span><h4>findstatic<a class="headerlink" href="#findstatic" title="Permalink to this headline">¶</a></h4>
<p>This command is only available if the <a class="reference internal" href="../howto/static-files/index.html"><span class="doc">static files application</span></a> (<code class="docutils literal"><span class="pre">django.contrib.staticfiles</span></code>) is installed.</p>
<p>Please refer to its <a class="reference internal" href="contrib/staticfiles.html#django-admin-findstatic"><code class="xref std std-djadmin docutils literal"><span class="pre">description</span></code></a> in the <a class="reference internal" href="contrib/staticfiles.html"><span class="doc">staticfiles</span></a> documentation.</p>
</div>
</div>
</div>
<div class="section" id="s-default-options">
<span id="default-options"></span><h2>Default options<a class="headerlink" href="#default-options" title="Permalink to this headline">¶</a></h2>
<p>Although some commands may allow their own custom options, every command
allows for the following options:</p>
<dl class="django-admin-option">
<dt id="django-admin-option---pythonpath">
<code class="descname">--pythonpath</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---pythonpath" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Adds the given filesystem path to the Python <a class="reference external" href="http://www.diveintopython.net/getting_to_know_python/everything_is_an_object.html">import search path</a>. If this
isn&#8217;t provided, <code class="docutils literal"><span class="pre">django-admin</span></code> will use the <code class="docutils literal"><span class="pre">PYTHONPATH</span></code> environment
variable.</p>
<p>Note that this option is unnecessary in <code class="docutils literal"><span class="pre">manage.py</span></code>, because it takes care of
setting the Python path for you.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---settings">
<code class="descname">--settings</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---settings" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Explicitly specifies the settings module to use. The settings module should be
in Python package syntax, e.g. <code class="docutils literal"><span class="pre">mysite.settings</span></code>. If this isn&#8217;t provided,
<code class="docutils literal"><span class="pre">django-admin</span></code> will use the <code class="docutils literal"><span class="pre">DJANGO_SETTINGS_MODULE</span></code> environment
variable.</p>
<p>Note that this option is unnecessary in <code class="docutils literal"><span class="pre">manage.py</span></code>, because it uses
<code class="docutils literal"><span class="pre">settings.py</span></code> from the current project by default.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---traceback">
<code class="descname">--traceback</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---traceback" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>By default, <code class="docutils literal"><span class="pre">django-admin</span></code> will show a simple error message whenever a
<a class="reference internal" href="../howto/custom-management-commands.html#django.core.management.CommandError" title="django.core.management.CommandError"><code class="xref py py-class docutils literal"><span class="pre">CommandError</span></code></a> occurs, but a full stack trace
for any other exception. If you specify <code class="docutils literal"><span class="pre">--traceback</span></code>, <code class="docutils literal"><span class="pre">django-admin</span></code>
will also output a full stack trace when a <code class="docutils literal"><span class="pre">CommandError</span></code> is raised.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---verbosity">
<code class="descname">--verbosity</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---verbosity" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Use <code class="docutils literal"><span class="pre">--verbosity</span></code> to specify the amount of notification and debug information
that <code class="docutils literal"><span class="pre">django-admin</span></code> should print to the console.</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">0</span></code> means no output.</li>
<li><code class="docutils literal"><span class="pre">1</span></code> means normal output (default).</li>
<li><code class="docutils literal"><span class="pre">2</span></code> means verbose output.</li>
<li><code class="docutils literal"><span class="pre">3</span></code> means <em>very</em> verbose output.</li>
</ul>
<dl class="django-admin-option">
<dt id="django-admin-option---no-color">
<code class="descname">--no-color</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---no-color" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.7.</span> </div>
<p>Example usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">django</span><span class="o">-</span><span class="n">admin</span> <span class="n">sqlall</span> <span class="o">--</span><span class="n">no</span><span class="o">-</span><span class="n">color</span>
</pre></div>
</div>
<p>By default, <code class="docutils literal"><span class="pre">django-admin</span></code> will format the output to be colorized. For
example, errors will be printed to the console in red and SQL statements will
be syntax highlighted. To prevent this and have a plain text output, pass the
<code class="docutils literal"><span class="pre">--no-color</span></code> option when running your command.</p>
</div>
<div class="section" id="s-common-options">
<span id="common-options"></span><h2>Common options<a class="headerlink" href="#common-options" title="Permalink to this headline">¶</a></h2>
<p>The following options are not available on every command, but they are common
to a number of commands.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---database">
<code class="descname">--database</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---database" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Used to specify the database on which a command will operate. If not
specified, this option will default to an alias of <code class="docutils literal"><span class="pre">default</span></code>.</p>
<p>For example, to dump data from the database with the alias <code class="docutils literal"><span class="pre">master</span></code>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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">database</span><span class="o">=</span><span class="n">master</span>
</pre></div>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---exclude">
<code class="descname">--exclude</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---exclude" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Exclude a specific application from the applications whose contents is
output. For example, to specifically exclude the <code class="docutils literal"><span class="pre">auth</span></code> application from
the output of dumpdata, you would call:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>If you want to exclude multiple applications, use multiple <code class="docutils literal"><span class="pre">--exclude</span></code>
directives:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---locale">
<code class="descname">--locale</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---locale" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--locale</span></code> or <code class="docutils literal"><span class="pre">-l</span></code> option to specify the locale to process.
If not provided all locales are processed.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---noinput">
<code class="descname">--noinput</code><code class="descclassname"></code><a class="headerlink" href="#django-admin-option---noinput" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <code class="docutils literal"><span class="pre">--noinput</span></code> option to suppress all user prompting, such as &#8220;Are
you sure?&#8221; confirmation messages. This is useful if <code class="docutils literal"><span class="pre">django-admin</span></code> is
being executed as an unattended, automated script.</p>
</div>
<div class="section" id="s-extra-niceties">
<span id="extra-niceties"></span><h2>Extra niceties<a class="headerlink" href="#extra-niceties" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-syntax-coloring">
<span id="s-id1"></span><span id="syntax-coloring"></span><span id="id1"></span><h3>Syntax coloring<a class="headerlink" href="#syntax-coloring" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal"><span class="pre">django-admin</span></code> / <code class="docutils literal"><span class="pre">manage.py</span></code> commands will use pretty
color-coded output if your terminal supports ANSI-colored output. It
won&#8217;t use the color codes if you&#8217;re piping the command&#8217;s output to
another program.</p>
<p>Under Windows, the native console doesn&#8217;t support ANSI escape sequences so by
default there is no color output. But you can install the <a class="reference external" href="http://adoxa.altervista.org/ansicon/">ANSICON</a>
third-party tool, the Django commands will detect its presence and will make
use of its services to color output just like on Unix-based platforms.</p>
<p>The colors used for syntax highlighting can be customized. Django
ships with three color palettes:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">dark</span></code>, suited to terminals that show white text on a black
background. This is the default palette.</li>
<li><code class="docutils literal"><span class="pre">light</span></code>, suited to terminals that show black text on a white
background.</li>
<li><code class="docutils literal"><span class="pre">nocolor</span></code>, which disables syntax highlighting.</li>
</ul>
<p>You select a palette by setting a <code class="docutils literal"><span class="pre">DJANGO_COLORS</span></code> environment
variable to specify the palette you want to use. For example, to
specify the <code class="docutils literal"><span class="pre">light</span></code> palette under a Unix or OS/X BASH shell, you
would run the following at a command prompt:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="n">DJANGO_COLORS</span><span class="o">=</span><span class="s2">&quot;light&quot;</span>
</pre></div>
</div>
<p>You can also customize the colors that are used. Django specifies a
number of roles in which color is used:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">error</span></code> - A major error.</li>
<li><code class="docutils literal"><span class="pre">notice</span></code> - A minor error.</li>
<li><code class="docutils literal"><span class="pre">warning</span></code> - A warning.</li>
<li><code class="docutils literal"><span class="pre">sql_field</span></code> - The name of a model field in SQL.</li>
<li><code class="docutils literal"><span class="pre">sql_coltype</span></code> - The type of a model field in SQL.</li>
<li><code class="docutils literal"><span class="pre">sql_keyword</span></code> - An SQL keyword.</li>
<li><code class="docutils literal"><span class="pre">sql_table</span></code> - The name of a model in SQL.</li>
<li><code class="docutils literal"><span class="pre">http_info</span></code> - A 1XX HTTP Informational server response.</li>
<li><code class="docutils literal"><span class="pre">http_success</span></code> - A 2XX HTTP Success server response.</li>
<li><code class="docutils literal"><span class="pre">http_not_modified</span></code> - A 304 HTTP Not Modified server response.</li>
<li><code class="docutils literal"><span class="pre">http_redirect</span></code> - A 3XX HTTP Redirect server response other than 304.</li>
<li><code class="docutils literal"><span class="pre">http_not_found</span></code> - A 404 HTTP Not Found server response.</li>
<li><code class="docutils literal"><span class="pre">http_bad_request</span></code> - A 4XX HTTP Bad Request server response other than 404.</li>
<li><code class="docutils literal"><span class="pre">http_server_error</span></code> - A 5XX HTTP Server Error response.</li>
<li><code class="docutils literal"><span class="pre">migrate_heading</span></code> - A heading in a migrations management command.</li>
<li><code class="docutils literal"><span class="pre">migrate_label</span></code> - A migration name.</li>
</ul>
<p>Each of these roles can be assigned a specific foreground and
background color, from the following list:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">black</span></code></li>
<li><code class="docutils literal"><span class="pre">red</span></code></li>
<li><code class="docutils literal"><span class="pre">green</span></code></li>
<li><code class="docutils literal"><span class="pre">yellow</span></code></li>
<li><code class="docutils literal"><span class="pre">blue</span></code></li>
<li><code class="docutils literal"><span class="pre">magenta</span></code></li>
<li><code class="docutils literal"><span class="pre">cyan</span></code></li>
<li><code class="docutils literal"><span class="pre">white</span></code></li>
</ul>
<p>Each of these colors can then be modified by using the following
display options:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">bold</span></code></li>
<li><code class="docutils literal"><span class="pre">underscore</span></code></li>
<li><code class="docutils literal"><span class="pre">blink</span></code></li>
<li><code class="docutils literal"><span class="pre">reverse</span></code></li>
<li><code class="docutils literal"><span class="pre">conceal</span></code></li>
</ul>
<p>A color specification follows one of the following patterns:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">role=fg</span></code></li>
<li><code class="docutils literal"><span class="pre">role=fg/bg</span></code></li>
<li><code class="docutils literal"><span class="pre">role=fg,option,option</span></code></li>
<li><code class="docutils literal"><span class="pre">role=fg/bg,option,option</span></code></li>
</ul>
<p>where <code class="docutils literal"><span class="pre">role</span></code> is the name of a valid color role, <code class="docutils literal"><span class="pre">fg</span></code> is the
foreground color, <code class="docutils literal"><span class="pre">bg</span></code> is the background color and each <code class="docutils literal"><span class="pre">option</span></code>
is one of the color modifying options. Multiple color specifications
are then separated by a semicolon. For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>would specify that errors be displayed using blinking yellow on blue,
and notices displayed using magenta. All other color roles would be
left uncolored.</p>
<p>Colors can also be specified by extending a base palette. If you put
a palette name in a color specification, all the colors implied by that
palette will be loaded. So:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>would specify the use of all the colors in the light color palette,
<em>except</em> for the colors for errors and notices which would be
overridden as specified.</p>
<div class="versionadded">
<span class="title">New in Django 1.7.</span> </div>
<p>Support for color-coded output from <code class="docutils literal"><span class="pre">django-admin</span></code> / <code class="docutils literal"><span class="pre">manage.py</span></code>
utilities on Windows by relying on the ANSICON application was added in Django
1.7.</p>
</div>
<div class="section" id="s-bash-completion">
<span id="bash-completion"></span><h3>Bash completion<a class="headerlink" href="#bash-completion" title="Permalink to this headline">¶</a></h3>
<p>If you use the Bash shell, consider installing the Django bash completion
script, which lives in <code class="docutils literal"><span class="pre">extras/django_bash_completion</span></code> in the Django
distribution. It enables tab-completion of <code class="docutils literal"><span class="pre">django-admin</span></code> and
<code class="docutils literal"><span class="pre">manage.py</span></code> commands, so you can, for instance...</p>
<ul class="simple">
<li>Type <code class="docutils literal"><span class="pre">django-admin</span></code>.</li>
<li>Press [TAB] to see all available options.</li>
<li>Type <code class="docutils literal"><span class="pre">sql</span></code>, then [TAB], to see all available options whose names start
with <code class="docutils literal"><span class="pre">sql</span></code>.</li>
</ul>
<p>See <a class="reference internal" href="../howto/custom-management-commands.html"><span class="doc">Writing custom django-admin commands</span></a> for how to add customized actions.</p>
</div>
</div>
</div>
<div class="section" id="s-running-management-commands-from-your-code">
<span id="running-management-commands-from-your-code"></span><h1>Running management commands from your code<a class="headerlink" href="#running-management-commands-from-your-code" title="Permalink to this headline">¶</a></h1>
<span class="target" id="call-command"></span><dl class="function">
<dt id="django.core.management.call_command">
<code class="descclassname">django.core.management.</code><code class="descname">call_command</code>(<em>name</em>, <em>*args</em>, <em>**options</em>)<a class="headerlink" href="#django.core.management.call_command" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>To call a management command from code use <code class="docutils literal"><span class="pre">call_command</span></code>.</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">name</span></code></dt>
<dd>the name of the command to call.</dd>
<dt><code class="docutils literal"><span class="pre">*args</span></code></dt>
<dd>a list of arguments accepted by the command.</dd>
<dt><code class="docutils literal"><span class="pre">**options</span></code></dt>
<dd>named options accepted on the command-line.</dd>
</dl>
<p>Examples:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.core</span> <span class="k">import</span> <span class="n">management</span>
<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>
<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>
</pre></div>
</div>
<p>Note that command options that take no arguments are passed as keywords
with <code class="docutils literal"><span class="pre">True</span></code> or <code class="docutils literal"><span class="pre">False</span></code>, as you can see with the <code class="docutils literal"><span class="pre">interactive</span></code> option above.</p>
<p>Named arguments can be passed by using either one of the following syntaxes:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># Similar to the command line</span>
<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>

<span class="c1"># Named argument similar to the command line minus the initial dashes and</span>
<span class="c1"># with internal dashes replaced by underscores</span>
<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>

<span class="c1"># `use_natural_foreign_keys` is the option destination variable</span>
<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>
</pre></div>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.8:</span> <p>The first syntax is now supported thanks to management commands using the
<code class="xref py py-mod docutils literal"><span class="pre">argparse</span></code> module. For the second syntax, Django previously passed
the option name as-is to the command, now it is always using the <code class="docutils literal"><span class="pre">dest</span></code>
variable name (which may or may not be the same as the option name).</p>
</div>
<p>Command options which take multiple options are passed a list:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<div class="section" id="s-output-redirection">
<span id="output-redirection"></span><h2>Output redirection<a class="headerlink" href="#output-redirection" title="Permalink to this headline">¶</a></h2>
<p>Note that you can redirect standard output and error streams as all commands
support the <code class="docutils literal"><span class="pre">stdout</span></code> and <code class="docutils literal"><span class="pre">stderr</span></code> options. For example, you could write:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><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="k">as</span> <span class="n">f</span><span class="p">:</span>
    <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>
</pre></div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">django-admin and manage.py</a><ul>
<li><a class="reference internal" href="#usage">Usage</a><ul>
<li><a class="reference internal" href="#getting-runtime-help">Getting runtime help</a></li>
<li><a class="reference internal" href="#app-names">App names</a></li>
<li><a class="reference internal" href="#determining-the-version">Determining the version</a></li>
<li><a class="reference internal" href="#displaying-debug-output">Displaying debug output</a></li>
</ul>
</li>
<li><a class="reference internal" href="#available-commands">Available commands</a><ul>
<li><a class="reference internal" href="#check-appname-appname">check &lt;appname appname ...&gt;</a></li>
<li><a class="reference internal" href="#compilemessages">compilemessages</a></li>
<li><a class="reference internal" href="#createcachetable">createcachetable</a></li>
<li><a class="reference internal" href="#dbshell">dbshell</a></li>
<li><a class="reference internal" href="#diffsettings">diffsettings</a></li>
<li><a class="reference internal" href="#dumpdata-app-label-app-label-app-label-model">dumpdata &lt;app_label app_label app_label.Model ...&gt;</a></li>
<li><a class="reference internal" href="#flush">flush</a><ul>
<li><a class="reference internal" href="#no-initial-data"><code class="docutils literal"><span class="pre">--no-initial-data</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#inspectdb">inspectdb</a></li>
<li><a class="reference internal" href="#loaddata-fixture-fixture">loaddata &lt;fixture fixture ...&gt;</a><ul>
<li><a class="reference internal" href="#what-s-a-fixture">What&#8217;s a &#8220;fixture&#8221;?</a></li>
<li><a class="reference internal" href="#compressed-fixtures">Compressed fixtures</a></li>
<li><a class="reference internal" href="#database-specific-fixtures">Database-specific fixtures</a></li>
</ul>
</li>
<li><a class="reference internal" href="#makemessages">makemessages</a></li>
<li><a class="reference internal" href="#makemigrations-app-label">makemigrations [&lt;app_label&gt;]</a></li>
<li><a class="reference internal" href="#migrate-app-label-migrationname">migrate [&lt;app_label&gt; [&lt;migrationname&gt;]]</a></li>
<li><a class="reference internal" href="#runfcgi-options">runfcgi [options]</a></li>
<li><a class="reference internal" href="#runserver-port-or-address-port">runserver [port or address:port]</a><ul>
<li><a class="reference internal" href="#examples-of-using-different-ports-and-addresses">Examples of using different ports and addresses</a></li>
<li><a class="reference internal" href="#serving-static-files-with-the-development-server">Serving static files with the development server</a></li>
</ul>
</li>
<li><a class="reference internal" href="#shell">shell</a></li>
<li><a class="reference internal" href="#showmigrations-app-label-app-label">showmigrations [&lt;app_label&gt; [&lt;app_label&gt;]]</a></li>
<li><a class="reference internal" href="#sql-app-label-app-label">sql &lt;app_label app_label ...&gt;</a></li>
<li><a class="reference internal" href="#sqlall-app-label-app-label">sqlall &lt;app_label app_label ...&gt;</a></li>
<li><a class="reference internal" href="#sqlclear-app-label-app-label">sqlclear &lt;app_label app_label ...&gt;</a></li>
<li><a class="reference internal" href="#sqlcustom-app-label-app-label">sqlcustom &lt;app_label app_label ...&gt;</a></li>
<li><a class="reference internal" href="#sqldropindexes-app-label-app-label">sqldropindexes &lt;app_label app_label ...&gt;</a></li>
<li><a class="reference internal" href="#sqlflush">sqlflush</a></li>
<li><a class="reference internal" href="#sqlindexes-app-label-app-label">sqlindexes &lt;app_label app_label ...&gt;</a></li>
<li><a class="reference internal" href="#sqlmigrate-app-label-migrationname">sqlmigrate &lt;app_label&gt; &lt;migrationname&gt;</a></li>
<li><a class="reference internal" href="#sqlsequencereset-app-label-app-label">sqlsequencereset &lt;app_label app_label ...&gt;</a></li>
<li><a class="reference internal" href="#squashmigrations-app-label-migration-name">squashmigrations &lt;app_label&gt; &lt;migration_name&gt;</a></li>
<li><a class="reference internal" href="#startapp-app-label-destination">startapp &lt;app_label&gt; [destination]</a></li>
<li><a class="reference internal" href="#startproject-projectname-destination">startproject &lt;projectname&gt; [destination]</a></li>
<li><a class="reference internal" href="#syncdb">syncdb</a></li>
<li><a class="reference internal" href="#test-app-or-test-identifier">test &lt;app or test identifier&gt;</a></li>
<li><a class="reference internal" href="#testserver-fixture-fixture">testserver &lt;fixture fixture ...&gt;</a></li>
<li><a class="reference internal" href="#validate">validate</a></li>
</ul>
</li>
<li><a class="reference internal" href="#commands-provided-by-applications">Commands provided by applications</a><ul>
<li><a class="reference internal" href="#django-contrib-auth"><code class="docutils literal"><span class="pre">django.contrib.auth</span></code></a><ul>
<li><a class="reference internal" href="#changepassword">changepassword</a></li>
<li><a class="reference internal" href="#createsuperuser">createsuperuser</a></li>
</ul>
</li>
<li><a class="reference internal" href="#django-contrib-gis"><code class="docutils literal"><span class="pre">django.contrib.gis</span></code></a><ul>
<li><a class="reference internal" href="#ogrinspect">ogrinspect</a></li>
</ul>
</li>
<li><a class="reference internal" href="#django-contrib-sessions"><code class="docutils literal"><span class="pre">django.contrib.sessions</span></code></a><ul>
<li><a class="reference internal" href="#clearsessions">clearsessions</a></li>
</ul>
</li>
<li><a class="reference internal" href="#django-contrib-sitemaps"><code class="docutils literal"><span class="pre">django.contrib.sitemaps</span></code></a><ul>
<li><a class="reference internal" href="#ping-google">ping_google</a></li>
</ul>
</li>
<li><a class="reference internal" href="#django-contrib-staticfiles"><code class="docutils literal"><span class="pre">django.contrib.staticfiles</span></code></a><ul>
<li><a class="reference internal" href="#collectstatic">collectstatic</a></li>
<li><a class="reference internal" href="#findstatic">findstatic</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#default-options">Default options</a></li>
<li><a class="reference internal" href="#common-options">Common options</a></li>
<li><a class="reference internal" href="#extra-niceties">Extra niceties</a><ul>
<li><a class="reference internal" href="#syntax-coloring">Syntax coloring</a></li>
<li><a class="reference internal" href="#bash-completion">Bash completion</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#running-management-commands-from-your-code">Running management commands from your code</a><ul>
<li><a class="reference internal" href="#output-redirection">Output redirection</a></li>
</ul>
</li>
</ul>

  <h3>Browse</h3>
  <ul>
    
      <li>Prev: <a href="databases.html">Databases</a></li>
    
    
      <li>Next: <a href="exceptions.html">Django Exceptions</a></li>
    
  </ul>
  <h3>You are here:</h3>
  <ul>
      <li>
        <a href="../index.html">Django 1.8.19 documentation</a>
        
          <ul><li><a href="index.html">API Reference</a>
        
        <ul><li>django-admin and manage.py</li></ul>
        </li></ul>
      </li>
  </ul>

  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/ref/django-admin.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Mar 10, 2018</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="databases.html" title="Databases">previous</a>
     |
    <a href="index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="exceptions.html" title="Django Exceptions">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>