Sophie

Sophie

distrib > Fedora > 20 > i386 > by-pkgid > 422242acff54b9373d7d4b7f73232ce1 > files > 636

python3-django-doc-1.6.7-1.fc20.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">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>django-admin.py and manage.py &mdash; Django 1.6.7 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.6.7',
        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="top" title="Django 1.6.7 documentation" href="../index.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>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../index.html">Django 1.6.7 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-py-and-manage-py">
<span id="django-admin-py-and-manage-py"></span><h1>django-admin.py and manage.py<a class="headerlink" href="#django-admin-py-and-manage-py" title="Permalink to this headline">¶</a></h1>
<p><tt class="docutils literal"><span class="pre">django-admin.py</span></tt> is Django&#8217;s command-line utility for administrative tasks.
This document outlines all it can do.</p>
<p>In addition, <tt class="docutils literal"><span class="pre">manage.py</span></tt> is automatically created in each Django project.
<tt class="docutils literal"><span class="pre">manage.py</span></tt> is a thin wrapper around <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> that takes care of
two things for you before delegating to <tt class="docutils literal"><span class="pre">django-admin.py</span></tt>:</p>
<ul class="simple">
<li>It puts your project&#8217;s package on <tt class="docutils literal"><span class="pre">sys.path</span></tt>.</li>
<li>It sets the <span class="target" id="index-0"></span><a class="reference internal" href="../topics/settings.html#envvar-DJANGO_SETTINGS_MODULE"><tt class="xref std std-envvar docutils literal"><span class="pre">DJANGO_SETTINGS_MODULE</span></tt></a> environment variable so that
it points to your project&#8217;s <tt class="docutils literal"><span class="pre">settings.py</span></tt> file.</li>
</ul>
<p>The <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> script should be on your system path if you installed
Django via its <tt class="docutils literal"><span class="pre">setup.py</span></tt> utility. If it&#8217;s not on your path, you can find it
in <tt class="docutils literal"><span class="pre">site-packages/django/bin</span></tt> within your Python installation. Consider
symlinking it from some place on your path, such as <tt class="docutils literal"><span class="pre">/usr/local/bin</span></tt>.</p>
<p>For Windows users, who do not have symlinking functionality available, you can
copy <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> to a location on your existing path or edit the
<tt class="docutils literal"><span class="pre">PATH</span></tt> settings (under <tt 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></tt>) to point to its installed location.</p>
<p>Generally, when working on a single Django project, it&#8217;s easier to use
<tt class="docutils literal"><span class="pre">manage.py</span></tt> than <tt class="docutils literal"><span class="pre">django-admin.py</span></tt>. If you need to switch between multiple
Django settings files, use <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> with
<span class="target" id="index-1"></span><a class="reference internal" href="../topics/settings.html#envvar-DJANGO_SETTINGS_MODULE"><tt class="xref std std-envvar docutils literal"><span class="pre">DJANGO_SETTINGS_MODULE</span></tt></a> or the <a class="reference internal" href="#django-admin-option---settings"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--settings</span></tt></a> command line
option.</p>
<p>The command-line examples throughout this document use <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> to
be consistent, but any example can use <tt class="docutils literal"><span class="pre">manage.py</span></tt> 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-bash"><div class="highlight"><pre>django-admin.py &lt;<span class="nb">command</span>&gt; <span class="o">[</span>options<span class="o">]</span>
manage.py &lt;<span class="nb">command</span>&gt; <span class="o">[</span>options<span class="o">]</span>
</pre></div>
</div>
<p><tt class="docutils literal"><span class="pre">command</span></tt> should be one of the commands listed in this document.
<tt class="docutils literal"><span class="pre">options</span></tt>, 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">
<tt class="descname">django-admin.py help</tt><a class="headerlink" href="#django-admin-help" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Run <tt class="docutils literal"><span class="pre">django-admin.py</span> <span class="pre">help</span></tt> to display usage information and a list of the
commands provided by each application.</p>
<p>Run <tt class="docutils literal"><span class="pre">django-admin.py</span> <span class="pre">help</span> <span class="pre">--commands</span></tt> to display a list of all available
commands.</p>
<p>Run <tt class="docutils literal"><span class="pre">django-admin.py</span> <span class="pre">help</span> <span class="pre">&lt;command&gt;</span></tt> 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"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a>
contains the string <tt class="docutils literal"><span class="pre">'mysite.blog'</span></tt>, the app name is <tt class="docutils literal"><span class="pre">blog</span></tt>.</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">
<tt class="descname">django-admin.py version</tt><a class="headerlink" href="#django-admin-version" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Run <tt class="docutils literal"><span class="pre">django-admin.py</span> <span class="pre">version</span></tt> 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="http://www.python.org/dev/peps/pep-0386"><strong>PEP 386</strong></a>:</p>
<div class="highlight-python"><pre>1.4.dev17026
1.4a1
1.4</pre>
</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"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--verbosity</span></tt></a> to specify the amount of notification and debug information
that <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> should print to the console. For more details, see the
documentation for the <a class="reference internal" href="#django-admin-option---verbosity"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--verbosity</span></tt></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">
<span id="check"></span><h3>check<a class="headerlink" href="#check" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-check">
<tt class="descname">django-admin.py check</tt><a class="headerlink" href="#django-admin-check" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.6.</span> </div>
<p>Performs a series of checks to verify a given setup (settings/application code)
is compatible with the current version of Django.</p>
<p>Upon finding things that are incompatible or require notifying the user, it
issues a series of warnings.</p>
</div>
<div class="section" id="s-cleanup">
<span id="cleanup"></span><h3>cleanup<a class="headerlink" href="#cleanup" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-cleanup">
<tt class="descname">django-admin.py cleanup</tt><a class="headerlink" href="#django-admin-cleanup" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Can be run as a cronjob or directly to clean out old data from the database
(only expired sessions at the moment).</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.5:</span> <a class="reference internal" href="#django-admin-cleanup"><tt class="xref std std-djadmin docutils literal"><span class="pre">cleanup</span></tt></a> is deprecated. Use <a class="reference internal" href="#django-admin-clearsessions"><tt class="xref std std-djadmin docutils literal"><span class="pre">clearsessions</span></tt></a> instead.</div>
</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">
<tt class="descname">django-admin.py compilemessages</tt><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"><tt class="xref std std-djadmin docutils literal"><span class="pre">makemessages</span></tt></a> to .mo files for use with
the builtin gettext support. See <a class="reference internal" href="../topics/i18n/index.html"><em>Internationalization and localization</em></a>.</p>
<p>Use the <a class="reference internal" href="#django-admin-option---locale"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--locale</span></tt></a> option (or its shorter version <tt class="docutils literal"><span class="pre">-l</span></tt>) to
specify the locale(s) to process. If not provided, all locales are processed.</p>
<p>Example usage:</p>
<div class="highlight-python"><pre>django-admin.py compilemessages --locale=pt_BR
django-admin.py compilemessages --locale=pt_BR --locale=fr
django-admin.py compilemessages -l pt_BR
django-admin.py compilemessages -l pt_BR -l fr</pre>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.6:</span> Added the ability to specify multiple locales.</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">
<tt class="descname">django-admin.py createcachetable</tt><a class="headerlink" href="#django-admin-createcachetable" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Creates a cache table named <tt class="docutils literal"><span class="pre">tablename</span></tt> for use with the database cache
backend. See <a class="reference internal" href="../topics/cache.html"><em>Django&#8217;s cache framework</em></a> for more information.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></a> option can be used to specify the database
onto which the cachetable will be installed.</p>
</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">
<tt class="descname">django-admin.py dbshell</tt><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
<tt class="docutils literal"><span class="pre">ENGINE</span></tt> setting, with the connection parameters specified in your
<a class="reference internal" href="settings.html#std:setting-USER"><tt class="xref std std-setting docutils literal"><span class="pre">USER</span></tt></a>, <a class="reference internal" href="settings.html#std:setting-PASSWORD"><tt class="xref std std-setting docutils literal"><span class="pre">PASSWORD</span></tt></a>, etc., settings.</p>
<ul class="simple">
<li>For PostgreSQL, this runs the <tt class="docutils literal"><span class="pre">psql</span></tt> command-line client.</li>
<li>For MySQL, this runs the <tt class="docutils literal"><span class="pre">mysql</span></tt> command-line client.</li>
<li>For SQLite, this runs the <tt class="docutils literal"><span class="pre">sqlite3</span></tt> command-line client.</li>
</ul>
<p>This command assumes the programs are on your <tt class="docutils literal"><span class="pre">PATH</span></tt> so that a simple call to
the program name (<tt class="docutils literal"><span class="pre">psql</span></tt>, <tt class="docutils literal"><span class="pre">mysql</span></tt>, <tt class="docutils literal"><span class="pre">sqlite3</span></tt>) 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"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></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">
<tt class="descname">django-admin.py diffsettings</tt><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 <tt class="docutils literal"><span class="pre">&quot;###&quot;</span></tt>. For
example, the default settings don&#8217;t define <a class="reference internal" href="settings.html#std:setting-ROOT_URLCONF"><tt class="xref std std-setting docutils literal"><span class="pre">ROOT_URLCONF</span></tt></a>, so
<a class="reference internal" href="settings.html#std:setting-ROOT_URLCONF"><tt class="xref std std-setting docutils literal"><span class="pre">ROOT_URLCONF</span></tt></a> is followed by <tt class="docutils literal"><span class="pre">&quot;###&quot;</span></tt> in the output of
<tt class="docutils literal"><span class="pre">diffsettings</span></tt>.</p>
<p>The <a class="reference internal" href="#django-admin-option---all"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--all</span></tt></a> option may be provided to display all settings, even
if they have Django&#8217;s default value. Such settings are prefixed by <tt class="docutils literal"><span class="pre">&quot;###&quot;</span></tt>.</p>
<div class="versionadded">
<span class="title">New in Django 1.6:</span> The <a class="reference internal" href="#django-admin-option---all"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--all</span></tt></a> option was added.</div>
</div>
<div class="section" id="s-dumpdata-appname-appname-appname-model">
<span id="dumpdata-appname-appname-appname-model"></span><h3>dumpdata &lt;appname appname appname.Model ...&gt;<a class="headerlink" href="#dumpdata-appname-appname-appname-model" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-dumpdata">
<tt class="descname">django-admin.py dumpdata</tt><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 <tt class="docutils literal"><span class="pre">dumpdata</span></tt> can be used as input for <a class="reference internal" href="#django-admin-loaddata"><tt class="xref std std-djadmin docutils literal"><span class="pre">loaddata</span></tt></a>.</p>
<p>Note that <tt class="docutils literal"><span class="pre">dumpdata</span></tt> 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"><em>custom manager</em></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"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--all</span></tt></a> option may be provided to specify that
<tt class="docutils literal"><span class="pre">dumpdata</span></tt> 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">
<tt class="descname">--format</tt><tt class="descclassname"> &lt;fmt&gt;</tt><a class="headerlink" href="#django-admin-option---format" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

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

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

<p>Use <a class="reference internal" href="../topics/serialization.html#topics-serialization-natural-keys"><em>natural keys</em></a> to represent
any foreign key and many-to-many relationship with a model that provides
a natural key definition. If you are dumping <tt class="docutils literal"><span class="pre">contrib.auth</span></tt> <tt class="docutils literal"><span class="pre">Permission</span></tt>
objects or <tt class="docutils literal"><span class="pre">contrib.contenttypes</span></tt> <tt class="docutils literal"><span class="pre">ContentType</span></tt> objects, you should
probably be using this flag.</p>
<div class="versionadded">
<span class="title">New in Django 1.6.</span> </div>
<dl class="django-admin-option">
<dt id="django-admin-option---pks">
<tt class="descname">--pks</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---pks" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

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

<p>Returns the database to the state it was in immediately after <a class="reference internal" href="#django-admin-syncdb"><tt class="xref std std-djadmin docutils literal"><span class="pre">syncdb</span></tt></a>
was executed. This means that all data will be removed from the database, any
post-synchronization handlers will be re-executed, and the <tt class="docutils literal"><span class="pre">initial_data</span></tt>
fixture will be re-installed.</p>
<p>The <a class="reference internal" href="#django-admin-option---noinput"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--noinput</span></tt></a> option may be provided to suppress all user
prompts.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></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><tt class="docutils literal"><span class="pre">--no-initial-data</span></tt><a class="headerlink" href="#no-initial-data" title="Permalink to this headline">¶</a></h4>
<div class="versionadded">
<span class="title">New in Django 1.5.</span> </div>
<p>Use <tt class="docutils literal"><span class="pre">--no-initial-data</span></tt> 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">
<tt class="descname">django-admin.py inspectdb</tt><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"><tt class="xref std std-setting docutils literal"><span class="pre">NAME</span></tt></a> setting and outputs a Django model module (a <tt class="docutils literal"><span class="pre">models.py</span></tt>
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 <tt class="docutils literal"><span class="pre">inspectdb</span></tt> has a few special cases in its field-name
output:</p>
<ul class="simple">
<li>If <tt class="docutils literal"><span class="pre">inspectdb</span></tt> cannot map a column&#8217;s type to a model field type, it&#8217;ll
use <tt class="docutils literal"><span class="pre">TextField</span></tt> and will insert the Python comment
<tt 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></tt> next to the field in the generated
model.</li>
<li>If the database column name is a Python reserved word (such as
<tt class="docutils literal"><span class="pre">'pass'</span></tt>, <tt class="docutils literal"><span class="pre">'class'</span></tt> or <tt class="docutils literal"><span class="pre">'for'</span></tt>), <tt class="docutils literal"><span class="pre">inspectdb</span></tt> will append
<tt class="docutils literal"><span class="pre">'_field'</span></tt> to the attribute name. For example, if a table has a column
<tt class="docutils literal"><span class="pre">'for'</span></tt>, the generated model will have a field <tt class="docutils literal"><span class="pre">'for_field'</span></tt>, with
the <tt class="docutils literal"><span class="pre">db_column</span></tt> attribute set to <tt class="docutils literal"><span class="pre">'for'</span></tt>. <tt class="docutils literal"><span class="pre">inspectdb</span></tt> will insert
the Python comment
<tt 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></tt> 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 <tt class="docutils literal"><span class="pre">primary_key=True</span></tt> where
needed.</p>
<p><tt class="docutils literal"><span class="pre">inspectdb</span></tt> 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"><tt class="xref py py-attr docutils literal"><span class="pre">default</span></tt></a> is specified on a model field.
Similarly, database defaults aren&#8217;t translated to model field defaults or
detected in any fashion by <tt class="docutils literal"><span class="pre">inspectdb</span></tt>.</p>
<p>By default, <tt class="docutils literal"><span class="pre">inspectdb</span></tt> creates unmanaged models. That is, <tt class="docutils literal"><span class="pre">managed</span> <span class="pre">=</span> <span class="pre">False</span></tt>
in the model&#8217;s <tt class="docutils literal"><span class="pre">Meta</span></tt> class tells Django not to manage each table&#8217;s creation
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"><tt class="xref py py-attr docutils literal"><span class="pre">managed</span></tt></a> option to
<tt class="docutils literal"><span class="pre">True</span></tt> (or simply remove it because <tt class="docutils literal"><span class="pre">True</span></tt> is its default value).</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></a> option may be used to specify the
database to introspect.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.6:</span> The behavior by which introspected models are created as unmanaged ones is new
in Django 1.6.</div>
</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">
<tt class="descname">django-admin.py loaddata</tt><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"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></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">
<tt class="descname">--ignorenonexistent</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---ignorenonexistent" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.5.</span> </div>
<p>The <a class="reference internal" href="#django-admin-option---ignorenonexistent"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--ignorenonexistent</span></tt></a> option can be used to ignore fields that
may have been removed from models since the fixture was originally generated.</p>
<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 <tt class="docutils literal"><span class="pre">fixtures</span></tt> directory of every installed application</li>
<li>In any directory named in the <a class="reference internal" href="settings.html#std:setting-FIXTURE_DIRS"><tt class="xref std std-setting docutils literal"><span class="pre">FIXTURE_DIRS</span></tt></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-python"><pre>django-admin.py loaddata mydata.json</pre>
</div>
<p>would only load JSON fixtures called <tt class="docutils literal"><span class="pre">mydata</span></tt>. The fixture extension
must correspond to the registered name of a
<a class="reference internal" href="../topics/serialization.html#serialization-formats"><em>serializer</em></a> (e.g., <tt class="docutils literal"><span class="pre">json</span></tt> or <tt class="docutils literal"><span class="pre">xml</span></tt>).</p>
<p>If you omit the extensions, Django will search all available fixture types
for a matching fixture. For example:</p>
<div class="highlight-python"><pre>django-admin.py loaddata mydata</pre>
</div>
<p>would look for any fixture of any fixture type called <tt class="docutils literal"><span class="pre">mydata</span></tt>. If a fixture
directory contained <tt class="docutils literal"><span class="pre">mydata.json</span></tt>, 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-python"><pre>django-admin.py loaddata foo/bar/mydata.json</pre>
</div>
<p>would search <tt class="docutils literal"><span class="pre">&lt;appname&gt;/fixtures/foo/bar/mydata.json</span></tt> for each installed
application,  <tt class="docutils literal"><span class="pre">&lt;dirname&gt;/foo/bar/mydata.json</span></tt> for each directory in
<a class="reference internal" href="settings.html#std:setting-FIXTURE_DIRS"><tt class="xref std std-setting docutils literal"><span class="pre">FIXTURE_DIRS</span></tt></a>, and the literal path <tt class="docutils literal"><span class="pre">foo/bar/mydata.json</span></tt>.</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"><tt class="xref py py-meth docutils literal"><span class="pre">save()</span></tt></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"><tt class="xref py py-data docutils literal"><span class="pre">pre_save</span></tt></a> or
<a class="reference internal" href="signals.html#django.db.models.signals.post_save" title="django.db.models.signals.post_save"><tt class="xref py py-data docutils literal"><span class="pre">post_save</span></tt></a> signals will be called with
<tt class="docutils literal"><span class="pre">raw=True</span></tt> 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-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.db.models.signals</span> <span class="kn">import</span> <span class="n">post_save</span>
<span class="kn">from</span> <span class="nn">.models</span> <span class="kn">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="c"># disable the handler during fixture loading</span>
    <span class="k">if</span> <span class="n">kwargs</span><span class="p">[</span><span class="s">&#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-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">functools</span> <span class="kn">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="s">&#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 <tt class="docutils literal"><span class="pre">loaddata</span></tt>.</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"><tt class="xref std std-djadmin docutils literal"><span class="pre">dumpdata</span></tt></a> command can be used to generate input for <tt class="docutils literal"><span class="pre">loaddata</span></tt>.</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 <tt class="docutils literal"><span class="pre">zip</span></tt>, <tt class="docutils literal"><span class="pre">gz</span></tt>, or <tt class="docutils literal"><span class="pre">bz2</span></tt> format. For example:</p>
<div class="highlight-python"><pre>django-admin.py loaddata mydata.json</pre>
</div>
<p>would look for any of <tt class="docutils literal"><span class="pre">mydata.json</span></tt>, <tt class="docutils literal"><span class="pre">mydata.json.zip</span></tt>,
<tt class="docutils literal"><span class="pre">mydata.json.gz</span></tt>, or <tt class="docutils literal"><span class="pre">mydata.json.bz2</span></tt>. 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 <tt class="docutils literal"><span class="pre">mydata.json</span></tt> and
<tt class="docutils literal"><span class="pre">mydata.xml.gz</span></tt> were found in the same fixture directory), fixture
installation will be aborted, and any data installed in the call to
<tt class="docutils literal"><span class="pre">loaddata</span></tt> 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 database identifier into the names of your fixtures.</p>
<p>For example, if your <a class="reference internal" href="settings.html#std:setting-DATABASES"><tt class="xref std std-setting docutils literal"><span class="pre">DATABASES</span></tt></a> setting has a &#8216;master&#8217; database
defined, name the fixture <tt class="docutils literal"><span class="pre">mydata.master.json</span></tt> or
<tt class="docutils literal"><span class="pre">mydata.master.json.gz</span></tt> and the fixture will only be loaded when you
specify you want to load data into the <tt class="docutils literal"><span class="pre">master</span></tt> 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">
<tt class="descname">django-admin.py makemessages</tt><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"><tt class="xref std std-djadmin docutils literal"><span class="pre">compilemessages</span></tt></a> for use with the builtin gettext support. See
the <a class="reference internal" href="../topics/i18n/translation.html#how-to-create-language-files"><em>i18n documentation</em></a> for details.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---all">
<tt class="descname">--all</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---all" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

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

<p>Use the <tt class="docutils literal"><span class="pre">--extension</span></tt> or <tt class="docutils literal"><span class="pre">-e</span></tt> 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-python"><pre>django-admin.py makemessages --locale=de --extension xhtml</pre>
</div>
<p>Separate multiple extensions with commas or use -e or &#8211;extension multiple times:</p>
<div class="highlight-python"><pre>django-admin.py makemessages --locale=de --extension=html,txt --extension xml</pre>
</div>
<p>Use the <a class="reference internal" href="#django-admin-option---locale"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--locale</span></tt></a> option (or its shorter version <tt class="docutils literal"><span class="pre">-l</span></tt>) to
specify the locale(s) to process.</p>
<p>Example usage:</p>
<div class="highlight-python"><pre>django-admin.py makemessages --locale=pt_BR
django-admin.py makemessages --locale=pt_BR --locale=fr
django-admin.py makemessages -l pt_BR
django-admin.py makemessages -l pt_BR -l fr</pre>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.6:</span> Added the ability to specify multiple locales.</div>
<dl class="django-admin-option">
<dt id="django-admin-option---domain">
<tt class="descname">--domain</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---domain" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

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

<p>Use the <tt class="docutils literal"><span class="pre">--symlinks</span></tt> or <tt class="docutils literal"><span class="pre">-s</span></tt> option to follow symlinks to directories when
looking for new translation strings.</p>
<p>Example usage:</p>
<div class="highlight-python"><pre>django-admin.py makemessages --locale=de --symlinks</pre>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---ignore">
<tt class="descname">--ignore</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---ignore" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

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

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

<p>Use the <tt class="docutils literal"><span class="pre">--no-wrap</span></tt> 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">
<tt class="descname">--no-location</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---no-location" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <tt class="docutils literal"><span class="pre">--no-location</span></tt> option to not write &#8216;<tt class="docutils literal"><span class="pre">#:</span> <span class="pre">filename:line</span></tt>’
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">
<tt class="descname">--keep-pot</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---keep-pot" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.6.</span> </div>
<p>Use the <tt class="docutils literal"><span class="pre">--keep-pot</span></tt> option to prevent django from deleting the temporary
.pot file 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>
<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">
<tt class="descname">django-admin.py runfcgi</tt><a class="headerlink" href="#django-admin-runfcgi" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<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"><em>FastCGI deployment documentation</em></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"><tt class="xref std std-setting docutils literal"><span class="pre">WSGI_APPLICATION</span></tt></a> setting.</p>
<p>The options accepted by this command are passed to the FastCGI library and
don&#8217;t use the <tt class="docutils literal"><span class="pre">'--'</span></tt> prefix as is usual for other Django management commands.</p>
<dl class="django-admin-option">
<dt id="django-admin-option-protocol">
<tt class="descname">protocol</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option-protocol" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

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

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

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

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

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

<p><tt class="docutils literal"><span class="pre">maxrequests=NUMBER</span></tt></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">
<tt class="descname">maxspare</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option-maxspare" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

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

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

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

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

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

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

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

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

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

<p><tt class="docutils literal"><span class="pre">umask=UMASK</span></tt></p>
<p>Umask to use when daemonizing. The value is interpreted as an octal number
(default value is <tt class="docutils literal"><span class="pre">0o22</span></tt>).</p>
<p>Example usage:</p>
<div class="highlight-python"><pre>django-admin.py runfcgi socket=/tmp/fcgi.sock method=prefork daemonize=true \
    pidfile=/var/run/django-fcgi.pid</pre>
</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">
<tt class="descname">django-admin.py runserver</tt><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 <tt class="docutils literal"><span class="pre">127.0.0.1</span></tt>. 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"><tt class="xref std std-setting docutils literal"><span class="pre">WSGI_APPLICATION</span></tt></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 or compiling translation files don&#8217;t
trigger a restart, so you&#8217;ll have to restart the server in these cases.</p>
<p>When you start the server, and each time you change Python code while the
server is running, the server will validate all of your installed models. (See
the <a class="reference internal" href="#django-admin-validate"><tt class="xref std std-djadmin docutils literal"><span class="pre">validate</span></tt></a> command below.) If the validator finds errors, it will
print them to standard output, but it won&#8217;t stop the server.</p>
<p>You can run as many servers as you want, as long as they&#8217;re on separate ports.
Just execute <tt class="docutils literal"><span class="pre">django-admin.py</span> <span class="pre">runserver</span></tt> more than once.</p>
<p>Note that the default IP address, <tt class="docutils literal"><span class="pre">127.0.0.1</span></tt>, 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. <tt class="docutils literal"><span class="pre">192.168.2.1</span></tt>) or
<tt class="docutils literal"><span class="pre">0.0.0.0</span></tt> or <tt class="docutils literal"><span class="pre">::</span></tt> (with IPv6 enabled).</p>
<p>You can provide an IPv6 address surrounded by brackets
(e.g. <tt class="docutils literal"><span class="pre">[200a::1]:8000</span></tt>). 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"><em>staticfiles</em></a> contrib app is enabled
(default in new projects) the <a class="reference internal" href="#django-admin-runserver"><tt class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></tt></a> command will be overriden
with its own <a class="reference internal" href="contrib/staticfiles.html#staticfiles-runserver"><em>runserver</em></a> command.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---noreload">
<tt class="descname">--noreload</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---noreload" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <tt class="docutils literal"><span class="pre">--noreload</span></tt> 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-python"><pre>django-admin.py runserver --noreload</pre>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---nothreading">
<tt class="descname">--nothreading</tt><tt class="descclassname"></tt><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 <tt class="docutils literal"><span class="pre">--nothreading</span></tt>
option to disable the use of threading in the development server.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---ipv6">
<tt class="descname">--ipv6</tt><tt class="descclassname"></tt><tt class="descclassname">, </tt><tt class="descname">-6</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---ipv6" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <tt class="docutils literal"><span class="pre">--ipv6</span></tt> (or shorter <tt class="docutils literal"><span class="pre">-6</span></tt>) option to tell Django to use IPv6 for
the development server. This changes the default IP address from
<tt class="docutils literal"><span class="pre">127.0.0.1</span></tt> to <tt class="docutils literal"><span class="pre">::1</span></tt>.</p>
<p>Example usage:</p>
<div class="highlight-python"><pre>django-admin.py runserver --ipv6</pre>
</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 <tt class="docutils literal"><span class="pre">127.0.0.1</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py runserver</pre>
</div>
<p>Port 8000 on IP address <tt class="docutils literal"><span class="pre">1.2.3.4</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py runserver 1.2.3.4:8000</pre>
</div>
<p>Port 7000 on IP address <tt class="docutils literal"><span class="pre">127.0.0.1</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py runserver 7000</pre>
</div>
<p>Port 7000 on IP address <tt class="docutils literal"><span class="pre">1.2.3.4</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py runserver 1.2.3.4:7000</pre>
</div>
<p>Port 8000 on IPv6 address <tt class="docutils literal"><span class="pre">::1</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py runserver -6</pre>
</div>
<p>Port 7000 on IPv6 address <tt class="docutils literal"><span class="pre">::1</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py runserver -6 7000</pre>
</div>
<p>Port 7000 on IPv6 address <tt class="docutils literal"><span class="pre">2001:0db8:1234:5678::9</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py runserver [2001:0db8:1234:5678::9]:7000</pre>
</div>
<p>Port 8000 on IPv4 address of host <tt class="docutils literal"><span class="pre">localhost</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py runserver localhost:8000</pre>
</div>
<p>Port 8000 on IPv6 address of host <tt class="docutils literal"><span class="pre">localhost</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py runserver -6 localhost:8000</pre>
</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"><tt class="xref std std-setting docutils literal"><span class="pre">MEDIA_URL</span></tt></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"><em>Managing static files (CSS, images)</em></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">
<tt class="descname">django-admin.py shell</tt><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 <tt class="docutils literal"><span class="pre">--plain</span></tt> option, like so:</p>
<div class="highlight-python"><pre>django-admin.py shell --plain</pre>
</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 <tt class="docutils literal"><span class="pre">-i</span></tt> or <tt class="docutils literal"><span class="pre">--interface</span></tt> options like so:</p>
<p>IPython:</p>
<div class="highlight-python"><pre>django-admin.py shell -i ipython
django-admin.py shell --interface ipython</pre>
</div>
<p>bpython:</p>
<div class="highlight-python"><pre>django-admin.py shell -i bpython
django-admin.py shell --interface bpython</pre>
</div>
<p>When the &#8220;plain&#8221; Python interactive interpreter starts (be it because
<tt class="docutils literal"><span class="pre">--plain</span></tt> 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><tt class="xref std std-envvar docutils literal"><span class="pre">PYTHONSTARTUP</span></tt>
environment variable and the <tt class="docutils literal"><span class="pre">~/.pythonrc.py</span></tt> script. If you don&#8217;t wish this
behavior you can use the <tt class="docutils literal"><span class="pre">--no-startup</span></tt> option. e.g.:</p>
<div class="highlight-python"><pre>django-admin.py shell --plain --no-startup</pre>
</div>
<div class="versionadded">
<span class="title">New in Django 1.5:</span> The <tt class="docutils literal"><span class="pre">--interface</span></tt> option was added in Django 1.5.</div>
<div class="versionadded">
<span class="title">New in Django 1.6:</span> The <tt class="docutils literal"><span class="pre">--no-startup</span></tt> option was added in Django 1.6.</div>
</div>
<div class="section" id="s-sql-appname-appname">
<span id="sql-appname-appname"></span><h3>sql &lt;appname appname ...&gt;<a class="headerlink" href="#sql-appname-appname" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sql">
<tt class="descname">django-admin.py sql</tt><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"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqlall-appname-appname">
<span id="sqlall-appname-appname"></span><h3>sqlall &lt;appname appname ...&gt;<a class="headerlink" href="#sqlall-appname-appname" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlall">
<tt class="descname">django-admin.py sqlall</tt><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"><tt class="xref std std-djadmin docutils literal"><span class="pre">sqlcustom</span></tt></a> for an explanation of how to
specify initial data.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqlclear-appname-appname">
<span id="sqlclear-appname-appname"></span><h3>sqlclear &lt;appname appname ...&gt;<a class="headerlink" href="#sqlclear-appname-appname" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlclear">
<tt class="descname">django-admin.py sqlclear</tt><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"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqlcustom-appname-appname">
<span id="sqlcustom-appname-appname"></span><h3>sqlcustom &lt;appname appname ...&gt;<a class="headerlink" href="#sqlcustom-appname-appname" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlcustom">
<tt class="descname">django-admin.py sqlcustom</tt><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
<tt class="docutils literal"><span class="pre">&lt;appname&gt;/sql/&lt;modelname&gt;.sql</span></tt>, where <tt class="docutils literal"><span class="pre">&lt;appname&gt;</span></tt> is the given app name and
<tt class="docutils literal"><span class="pre">&lt;modelname&gt;</span></tt> is the model&#8217;s name in lowercase. For example, if you have an
app <tt class="docutils literal"><span class="pre">news</span></tt> that includes a <tt class="docutils literal"><span class="pre">Story</span></tt> model, <tt class="docutils literal"><span class="pre">sqlcustom</span></tt> will attempt
to read a file <tt class="docutils literal"><span class="pre">news/sql/story.sql</span></tt> 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"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqldropindexes-appname-appname">
<span id="sqldropindexes-appname-appname"></span><h3>sqldropindexes &lt;appname appname ...&gt;<a class="headerlink" href="#sqldropindexes-appname-appname" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqldropindexes">
<tt class="descname">django-admin.py sqldropindexes</tt><a class="headerlink" href="#django-admin-sqldropindexes" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.6.</span> </div>
<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"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></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">
<tt class="descname">django-admin.py sqlflush</tt><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"><tt class="xref std std-djadmin docutils literal"><span class="pre">flush</span></tt></a>
command.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqlindexes-appname-appname">
<span id="sqlindexes-appname-appname"></span><h3>sqlindexes &lt;appname appname ...&gt;<a class="headerlink" href="#sqlindexes-appname-appname" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlindexes">
<tt class="descname">django-admin.py sqlindexes</tt><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"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-sqlsequencereset-appname-appname">
<span id="sqlsequencereset-appname-appname"></span><h3>sqlsequencereset &lt;appname appname ...&gt;<a class="headerlink" href="#sqlsequencereset-appname-appname" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-sqlsequencereset">
<tt class="descname">django-admin.py sqlsequencereset</tt><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"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></a> option can be used to specify the database for
which to print the SQL.</p>
</div>
<div class="section" id="s-startapp-appname-destination">
<span id="startapp-appname-destination"></span><h3>startapp &lt;appname&gt; [destination]<a class="headerlink" href="#startapp-appname-destination" title="Permalink to this headline">¶</a></h3>
<dl class="django-admin">
<dt id="django-admin-startapp">
<tt class="descname">django-admin.py startapp</tt><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 <tt class="docutils literal"><span class="pre">models.py</span></tt> 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-python"><pre>django-admin.py startapp myapp /Users/jezdez/Code/myapp</pre>
</div>
<span class="target" id="custom-app-and-project-templates"></span><dl class="django-admin-option">
<dt id="django-admin-option---template">
<tt class="descname">--template</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---template" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>With the <tt class="docutils literal"><span class="pre">--template</span></tt> 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 (<tt class="docutils literal"><span class="pre">.tar.gz</span></tt>, <tt class="docutils literal"><span class="pre">.tar.bz2</span></tt>, <tt class="docutils literal"><span class="pre">.tgz</span></tt>, <tt class="docutils literal"><span class="pre">.tbz</span></tt>, <tt class="docutils literal"><span class="pre">.zip</span></tt>)
containing the app template files.</p>
<p>For example, this would look for an app template in the given directory when
creating the <tt class="docutils literal"><span class="pre">myapp</span></tt> app:</p>
<div class="highlight-python"><pre>django-admin.py startapp --template=/Users/jezdez/Code/my_app_template myapp</pre>
</div>
<p>Django will also accept URLs (<tt class="docutils literal"><span class="pre">http</span></tt>, <tt class="docutils literal"><span class="pre">https</span></tt>, <tt class="docutils literal"><span class="pre">ftp</span></tt>) 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-python"><pre>django-admin.py startapp --template=https://github.com/githubuser/django-app-template/archive/master.zip myapp</pre>
</div>
<p>When Django copies the app template files, it also renders certain files
through the template engine: the files whose extensions match the
<tt class="docutils literal"><span class="pre">--extension</span></tt> option (<tt class="docutils literal"><span class="pre">py</span></tt> by default) and the files whose names are passed
with the <tt class="docutils literal"><span class="pre">--name</span></tt> option. The <a class="reference internal" href="templates/api.html#django.template.Context" title="django.template.Context"><tt class="xref py py-class docutils literal"><span class="pre">template</span> <span class="pre">context</span></tt></a> used is:</p>
<ul class="simple">
<li>Any option passed to the <tt class="docutils literal"><span class="pre">startapp</span></tt> command (among the command&#8217;s supported
options)</li>
<li><tt class="docutils literal"><span class="pre">app_name</span></tt> &#8211; the app name as passed to the command</li>
<li><tt class="docutils literal"><span class="pre">app_directory</span></tt> &#8211; the full path of the newly created app</li>
<li><tt class="docutils literal"><span class="pre">docs_version</span></tt> &#8211; the version of the documentation: <tt class="docutils literal"><span class="pre">'dev'</span></tt> or <tt class="docutils literal"><span class="pre">'1.x'</span></tt></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 <tt class="docutils literal"><span class="pre">*.py</span></tt> 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"><tt class="xref std std-ttag docutils literal"><span class="pre">templatetag</span></tt></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">
<tt class="descname">django-admin.py startproject</tt><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 <tt class="docutils literal"><span class="pre">manage.py</span></tt> and a project package
(containing a <tt class="docutils literal"><span class="pre">settings.py</span></tt> 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 <tt class="docutils literal"><span class="pre">&lt;projectname&gt;</span></tt> 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 <tt class="docutils literal"><span class="pre">manage.py</span></tt> and the project
package within it. Use &#8216;.&#8217; to denote the current working directory.</p>
<p>For example:</p>
<div class="highlight-python"><pre>django-admin.py startproject myproject /Users/jezdez/Code/myproject_repo</pre>
</div>
<p>As with the <a class="reference internal" href="#django-admin-startapp"><tt class="xref std std-djadmin docutils literal"><span class="pre">startapp</span></tt></a> command, the <tt class="docutils literal"><span class="pre">--template</span></tt> 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"><tt class="xref std std-djadmin docutils literal"><span class="pre">startapp</span></tt></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 <tt class="docutils literal"><span class="pre">myproject</span></tt> project:</p>
<div class="highlight-python"><pre>django-admin.py startproject --template=/Users/jezdez/Code/my_project_template myproject</pre>
</div>
<p>Django will also accept URLs (<tt class="docutils literal"><span class="pre">http</span></tt>, <tt class="docutils literal"><span class="pre">https</span></tt>, <tt class="docutils literal"><span class="pre">ftp</span></tt>) 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-python"><pre>django-admin.py startproject --template=https://github.com/githubuser/django-project-template/archive/master.zip myproject</pre>
</div>
<p>When Django copies the project template files, it also renders certain files
through the template engine: the files whose extensions match the
<tt class="docutils literal"><span class="pre">--extension</span></tt> option (<tt class="docutils literal"><span class="pre">py</span></tt> by default) and the files whose names are passed
with the <tt class="docutils literal"><span class="pre">--name</span></tt> option. The <a class="reference internal" href="templates/api.html#django.template.Context" title="django.template.Context"><tt class="xref py py-class docutils literal"><span class="pre">template</span> <span class="pre">context</span></tt></a> used is:</p>
<ul class="simple">
<li>Any option passed to the <tt class="docutils literal"><span class="pre">startproject</span></tt> command (among the command&#8217;s
supported options)</li>
<li><tt class="docutils literal"><span class="pre">project_name</span></tt> &#8211; the project name as passed to the command</li>
<li><tt class="docutils literal"><span class="pre">project_directory</span></tt> &#8211; the full path of the newly created project</li>
<li><tt class="docutils literal"><span class="pre">secret_key</span></tt> &#8211; a random key for the <a class="reference internal" href="settings.html#std:setting-SECRET_KEY"><tt class="xref std std-setting docutils literal"><span class="pre">SECRET_KEY</span></tt></a> setting</li>
<li><tt class="docutils literal"><span class="pre">docs_version</span></tt> &#8211; the version of the documentation: <tt class="docutils literal"><span class="pre">'dev'</span></tt> or <tt class="docutils literal"><span class="pre">'1.x'</span></tt></li>
</ul>
<p>Please also see the <a class="reference internal" href="#render-warning"><em>rendering warning</em></a> as mentioned
for <a class="reference internal" href="#django-admin-startapp"><tt class="xref std std-djadmin docutils literal"><span class="pre">startapp</span></tt></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">
<tt class="descname">django-admin.py syncdb</tt><a class="headerlink" href="#django-admin-syncdb" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Creates the database tables for all apps in <a class="reference internal" href="settings.html#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a> whose
tables have not already been created.</p>
<p>Use this command when you&#8217;ve added new applications to your project and want to
install them in the database. This includes any apps shipped with Django that
might be in <a class="reference internal" href="settings.html#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a> by default. When you start a new project,
run this command to install the default apps.</p>
<div class="admonition-syncdb-will-not-alter-existing-tables admonition">
<p class="first admonition-title">Syncdb will not alter existing tables</p>
<p><tt class="docutils literal"><span class="pre">syncdb</span></tt> will only create tables for models which have not yet been
installed. It will <em>never</em> issue <tt class="docutils literal"><span class="pre">ALTER</span> <span class="pre">TABLE</span></tt> statements to match
changes made to a model class after installation. Changes to model classes
and database schemas often involve some form of ambiguity and, in those
cases, Django would have to guess at the correct changes to make. There is
a risk that critical data would be lost in the process.</p>
<p class="last">If you have made changes to a model and wish to alter the database tables
to match, use the <tt class="docutils literal"><span class="pre">sql</span></tt> command to display the new SQL structure and
compare that to your existing table schema to work out the changes.</p>
</div>
<p>If you&#8217;re installing the <tt class="docutils literal"><span class="pre">django.contrib.auth</span></tt> application, <tt class="docutils literal"><span class="pre">syncdb</span></tt> will
give you the option of creating a superuser immediately.</p>
<p><tt class="docutils literal"><span class="pre">syncdb</span></tt> will also search for and install any fixture named <tt class="docutils literal"><span class="pre">initial_data</span></tt>
with an appropriate extension (e.g. <tt class="docutils literal"><span class="pre">json</span></tt> or <tt class="docutils literal"><span class="pre">xml</span></tt>). See the
documentation for <tt class="docutils literal"><span class="pre">loaddata</span></tt> for details on the specification of fixture
data files.</p>
<p>The <a class="reference internal" href="#django-admin-option---noinput"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--noinput</span></tt></a> option may be provided to suppress all user
prompts.</p>
<p>The <a class="reference internal" href="#django-admin-option---database"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--database</span></tt></a> option can be used to specify the database to
synchronize.</p>
<div class="section" id="s-id1">
<span id="id1"></span><h4><tt class="docutils literal"><span class="pre">--no-initial-data</span></tt><a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h4>
<div class="versionadded">
<span class="title">New in Django 1.5.</span> </div>
<p>Use <tt class="docutils literal"><span class="pre">--no-initial-data</span></tt> to avoid loading the initial_data fixture.</p>
</div>
</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">
<tt class="descname">django-admin.py test</tt><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"><em>Testing in Django</em></a> for more
information.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---failfast">
<tt class="descname">--failfast</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---failfast" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <tt class="docutils literal"><span class="pre">--failfast</span></tt> 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">
<tt class="descname">--testrunner</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---testrunner" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <tt class="docutils literal"><span class="pre">--testrunner</span></tt> 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"><tt class="xref std std-setting docutils literal"><span class="pre">TEST_RUNNER</span></tt></a> setting.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---liveserver">
<tt class="descname">--liveserver</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---liveserver" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <tt class="docutils literal"><span class="pre">--liveserver</span></tt> 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"><tt class="xref py py-class docutils literal"><span class="pre">LiveServerTestCase</span></tt></a>) is
expected to run from. The default value is <tt class="docutils literal"><span class="pre">localhost:8081</span></tt>.</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">
<tt class="descname">django-admin.py testserver</tt><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"><tt class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></tt></a>) using data from
the given fixture(s).</p>
<p>For example, this command:</p>
<div class="highlight-python"><pre>django-admin.py testserver mydata.json</pre>
</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"><em>The test database</em></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"><tt class="xref std std-djadmin docutils literal"><span class="pre">loaddata</span></tt></a> above.)</li>
<li>Runs the Django development server (as in <a class="reference internal" href="#django-admin-runserver"><tt class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></tt></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"><em>unit tests</em></a> of how your views
act with certain fixture data, you can use <tt class="docutils literal"><span class="pre">testserver</span></tt> 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"><tt class="xref std std-djadmin docutils literal"><span class="pre">dumpdata</span></tt></a> command, explained
above), then use <tt class="docutils literal"><span class="pre">testserver</span></tt> 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"><tt class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></tt></a> does). It does, however, detect changes to
templates.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---addrport">
<tt class="descname">--addrport</tt><tt class="descclassname"> [port number or ipaddr:port]</tt><a class="headerlink" href="#django-admin-option---addrport" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use <tt class="docutils literal"><span class="pre">--addrport</span></tt> to specify a different port, or IP address and port, from
the default of <tt class="docutils literal"><span class="pre">127.0.0.1:8000</span></tt>. 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"><tt class="xref std std-djadmin docutils literal"><span class="pre">runserver</span></tt></a>
command.</p>
<p>Examples:</p>
<p>To run the test server on port 7000 with <tt class="docutils literal"><span class="pre">fixture1</span></tt> and <tt class="docutils literal"><span class="pre">fixture2</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py testserver --addrport 7000 fixture1 fixture2
django-admin.py testserver fixture1 fixture2 --addrport 7000</pre>
</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 <tt class="docutils literal"><span class="pre">test</span></tt> fixture:</p>
<div class="highlight-python"><pre>django-admin.py testserver --addrport 1.2.3.4:7000 test</pre>
</div>
<p>The <a class="reference internal" href="#django-admin-option---noinput"><tt class="xref std std-djadminopt docutils literal"><span class="pre">--noinput</span></tt></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">
<tt class="descname">django-admin.py validate</tt><a class="headerlink" href="#django-admin-validate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Validates all installed models (according to the <a class="reference internal" href="settings.html#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></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 <tt class="docutils literal"><span class="pre">django.contrib</span></tt> application that
<a class="reference internal" href="../howto/custom-management-commands.html"><em>implements</em></a> them has been
<a class="reference internal" href="settings.html#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">enabled</span></tt></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><tt class="docutils literal"><span class="pre">django.contrib.auth</span></tt><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">
<tt class="descname">django-admin.py changepassword</tt><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"><em>authentication system</em></a> (<tt class="docutils literal"><span class="pre">django.contrib.auth</span></tt>) is installed.</p>
<p>Allows changing a user&#8217;s password. It prompts you to enter twice the password of
the user given as parameter. If they both match, the new password will be
changed immediately. 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 <tt class="docutils literal"><span class="pre">--database</span></tt> option to specify the database to query for the user. If
it&#8217;s not supplied, Django will use the <tt class="docutils literal"><span class="pre">default</span></tt> database.</p>
<p>Example usage:</p>
<div class="highlight-python"><pre>django-admin.py changepassword ringo</pre>
</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">
<tt class="descname">django-admin.py createsuperuser</tt><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"><em>authentication system</em></a> (<tt class="docutils literal"><span class="pre">django.contrib.auth</span></tt>) 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 but did not
do so during <a class="reference internal" href="#django-admin-syncdb"><tt class="xref std std-djadmin docutils literal"><span class="pre">syncdb</span></tt></a>, 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">
<tt class="descname">--username</tt><tt class="descclassname"></tt><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">
<tt class="descname">--email</tt><tt class="descclassname"></tt><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 <tt class="docutils literal"><span class="pre">--username</span></tt> and <tt class="docutils literal"><span class="pre">--email</span></tt> arguments on the command
line. If either of those is not supplied, <tt class="docutils literal"><span class="pre">createsuperuser</span></tt> will prompt for
it when running interactively.</p>
<p>Use the <tt class="docutils literal"><span class="pre">--database</span></tt> option to specify the database into which the superuser
object will be saved.</p>
</div>
</div>
<div class="section" id="s-django-contrib-gis">
<span id="django-contrib-gis"></span><h3><tt class="docutils literal"><span class="pre">django.contrib.gis</span></tt><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"><em>GeoDjango</em></a>
(<tt class="docutils literal"><span class="pre">django.contrib.gis</span></tt>) is installed.</p>
<p>Please refer to its <a class="reference internal" href="contrib/gis/commands.html#django-admin-ogrinspect"><tt class="xref std std-djadmin docutils literal"><span class="pre">description</span></tt></a> in the GeoDjango
documentation.</p>
</div>
</div>
<div class="section" id="s-django-contrib-sessions">
<span id="django-contrib-sessions"></span><h3><tt class="docutils literal"><span class="pre">django.contrib.sessions</span></tt><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">
<tt class="descname">django-admin.py clearsessions</tt><a class="headerlink" href="#django-admin-clearsessions" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.5.</span> </div>
<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><tt class="docutils literal"><span class="pre">django.contrib.sitemaps</span></tt><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"><em>Sitemaps framework</em></a> (<tt class="docutils literal"><span class="pre">django.contrib.sitemaps</span></tt>) is installed.</p>
<p>Please refer to its <a class="reference internal" href="contrib/sitemaps.html#django-admin-ping_google"><tt class="xref std std-djadmin docutils literal"><span class="pre">description</span></tt></a> in the Sitemaps
documentation.</p>
</div>
</div>
<div class="section" id="s-django-contrib-staticfiles">
<span id="django-contrib-staticfiles"></span><h3><tt class="docutils literal"><span class="pre">django.contrib.staticfiles</span></tt><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"><em>static files application</em></a> (<tt class="docutils literal"><span class="pre">django.contrib.staticfiles</span></tt>) is installed.</p>
<p>Please refer to its <a class="reference internal" href="contrib/staticfiles.html#django-admin-collectstatic"><tt class="xref std std-djadmin docutils literal"><span class="pre">description</span></tt></a> in the
<a class="reference internal" href="contrib/staticfiles.html"><em>staticfiles</em></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"><em>static files application</em></a> (<tt class="docutils literal"><span class="pre">django.contrib.staticfiles</span></tt>) is installed.</p>
<p>Please refer to its <a class="reference internal" href="contrib/staticfiles.html#django-admin-findstatic"><tt class="xref std std-djadmin docutils literal"><span class="pre">description</span></tt></a> in the <a class="reference internal" href="contrib/staticfiles.html"><em>staticfiles</em></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">
<tt class="descname">--pythonpath</tt><tt class="descclassname"></tt><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-python"><pre>django-admin.py syncdb --pythonpath='/home/djangoprojects/myproject'</pre>
</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, <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> will use the <tt class="docutils literal"><span class="pre">PYTHONPATH</span></tt> environment
variable.</p>
<p>Note that this option is unnecessary in <tt class="docutils literal"><span class="pre">manage.py</span></tt>, because it takes care of
setting the Python path for you.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---settings">
<tt class="descname">--settings</tt><tt class="descclassname"></tt><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-python"><pre>django-admin.py syncdb --settings=mysite.settings</pre>
</div>
<p>Explicitly specifies the settings module to use. The settings module should be
in Python package syntax, e.g. <tt class="docutils literal"><span class="pre">mysite.settings</span></tt>. If this isn&#8217;t provided,
<tt class="docutils literal"><span class="pre">django-admin.py</span></tt> will use the <tt class="docutils literal"><span class="pre">DJANGO_SETTINGS_MODULE</span></tt> environment
variable.</p>
<p>Note that this option is unnecessary in <tt class="docutils literal"><span class="pre">manage.py</span></tt>, because it uses
<tt class="docutils literal"><span class="pre">settings.py</span></tt> from the current project by default.</p>
<dl class="django-admin-option">
<dt id="django-admin-option---traceback">
<tt class="descname">--traceback</tt><tt class="descclassname"></tt><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-python"><pre>django-admin.py syncdb --traceback</pre>
</div>
<p>By default, <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> will show a simple error message whenever an
<a class="reference internal" href="../howto/custom-management-commands.html#django.core.management.CommandError" title="django.core.management.CommandError"><tt class="xref py py-class docutils literal"><span class="pre">CommandError</span></tt></a> occurs, but a full stack trace
for any other exception. If you specify <tt class="docutils literal"><span class="pre">--traceback</span></tt>, <tt class="docutils literal"><span class="pre">django-admin.py</span></tt>
will also output a full stack trace when a <tt class="docutils literal"><span class="pre">CommandError</span></tt> is raised.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.6:</span> Previously, Django didn&#8217;t show a full stack trace by default for exceptions
other than <tt class="docutils literal"><span class="pre">CommandError</span></tt>.</div>
<dl class="django-admin-option">
<dt id="django-admin-option---verbosity">
<tt class="descname">--verbosity</tt><tt class="descclassname"></tt><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-python"><pre>django-admin.py syncdb --verbosity 2</pre>
</div>
<p>Use <tt class="docutils literal"><span class="pre">--verbosity</span></tt> to specify the amount of notification and debug information
that <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> should print to the console.</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">0</span></tt> means no output.</li>
<li><tt class="docutils literal"><span class="pre">1</span></tt> means normal output (default).</li>
<li><tt class="docutils literal"><span class="pre">2</span></tt> means verbose output.</li>
<li><tt class="docutils literal"><span class="pre">3</span></tt> means <em>very</em> verbose output.</li>
</ul>
</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">
<tt class="descname">--database</tt><tt class="descclassname"></tt><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 <tt class="docutils literal"><span class="pre">default</span></tt>.</p>
<p>For example, to dump data from the database with the alias <tt class="docutils literal"><span class="pre">master</span></tt>:</p>
<div class="highlight-python"><pre>django-admin.py dumpdata --database=master</pre>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---exclude">
<tt class="descname">--exclude</tt><tt class="descclassname"></tt><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 <tt class="docutils literal"><span class="pre">auth</span></tt> application from
the output of dumpdata, you would call:</p>
<div class="highlight-python"><pre>django-admin.py dumpdata --exclude=auth</pre>
</div>
<p>If you want to exclude multiple applications, use multiple <tt class="docutils literal"><span class="pre">--exclude</span></tt>
directives:</p>
<div class="highlight-python"><pre>django-admin.py dumpdata --exclude=auth --exclude=contenttypes</pre>
</div>
<dl class="django-admin-option">
<dt id="django-admin-option---locale">
<tt class="descname">--locale</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---locale" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <tt class="docutils literal"><span class="pre">--locale</span></tt> or <tt class="docutils literal"><span class="pre">-l</span></tt> 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">
<tt class="descname">--noinput</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---noinput" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Use the <tt class="docutils literal"><span class="pre">--noinput</span></tt> option to suppress all user prompting, such as &#8220;Are
you sure?&#8221; confirmation messages. This is useful if <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> 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-id2"></span><span id="syntax-coloring"></span><span id="id2"></span><h3>Syntax coloring<a class="headerlink" href="#syntax-coloring" title="Permalink to this headline">¶</a></h3>
<p>The <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> / <tt class="docutils literal"><span class="pre">manage.py</span></tt> 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>The colors used for syntax highlighting can be customized. Django
ships with three color palettes:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">dark</span></tt>, suited to terminals that show white text on a black
background. This is the default palette.</li>
<li><tt class="docutils literal"><span class="pre">light</span></tt>, suited to terminals that show black text on a white
background.</li>
<li><tt class="docutils literal"><span class="pre">nocolor</span></tt>, which disables syntax highlighting.</li>
</ul>
<p>You select a palette by setting a <tt class="docutils literal"><span class="pre">DJANGO_COLORS</span></tt> environment
variable to specify the palette you want to use. For example, to
specify the <tt class="docutils literal"><span class="pre">light</span></tt> palette under a Unix or OS/X BASH shell, you
would run the following at a command prompt:</p>
<div class="highlight-python"><pre>export DJANGO_COLORS="light"</pre>
</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><tt class="docutils literal"><span class="pre">error</span></tt> - A major error.</li>
<li><tt class="docutils literal"><span class="pre">notice</span></tt> - A minor error.</li>
<li><tt class="docutils literal"><span class="pre">sql_field</span></tt> - The name of a model field in SQL.</li>
<li><tt class="docutils literal"><span class="pre">sql_coltype</span></tt> - The type of a model field in SQL.</li>
<li><tt class="docutils literal"><span class="pre">sql_keyword</span></tt> - An SQL keyword.</li>
<li><tt class="docutils literal"><span class="pre">sql_table</span></tt> - The name of a model in SQL.</li>
<li><tt class="docutils literal"><span class="pre">http_info</span></tt> - A 1XX HTTP Informational server response.</li>
<li><tt class="docutils literal"><span class="pre">http_success</span></tt> - A 2XX HTTP Success server response.</li>
<li><tt class="docutils literal"><span class="pre">http_not_modified</span></tt> - A 304 HTTP Not Modified server response.</li>
<li><tt class="docutils literal"><span class="pre">http_redirect</span></tt> - A 3XX HTTP Redirect server response other than 304.</li>
<li><tt class="docutils literal"><span class="pre">http_not_found</span></tt> - A 404 HTTP Not Found server response.</li>
<li><tt class="docutils literal"><span class="pre">http_bad_request</span></tt> - A 4XX HTTP Bad Request server response other than 404.</li>
<li><tt class="docutils literal"><span class="pre">http_server_error</span></tt> - A 5XX HTTP Server Error response.</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><tt class="docutils literal"><span class="pre">black</span></tt></li>
<li><tt class="docutils literal"><span class="pre">red</span></tt></li>
<li><tt class="docutils literal"><span class="pre">green</span></tt></li>
<li><tt class="docutils literal"><span class="pre">yellow</span></tt></li>
<li><tt class="docutils literal"><span class="pre">blue</span></tt></li>
<li><tt class="docutils literal"><span class="pre">magenta</span></tt></li>
<li><tt class="docutils literal"><span class="pre">cyan</span></tt></li>
<li><tt class="docutils literal"><span class="pre">white</span></tt></li>
</ul>
<p>Each of these colors can then be modified by using the following
display options:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">bold</span></tt></li>
<li><tt class="docutils literal"><span class="pre">underscore</span></tt></li>
<li><tt class="docutils literal"><span class="pre">blink</span></tt></li>
<li><tt class="docutils literal"><span class="pre">reverse</span></tt></li>
<li><tt class="docutils literal"><span class="pre">conceal</span></tt></li>
</ul>
<p>A color specification follows one of the following patterns:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">role=fg</span></tt></li>
<li><tt class="docutils literal"><span class="pre">role=fg/bg</span></tt></li>
<li><tt class="docutils literal"><span class="pre">role=fg,option,option</span></tt></li>
<li><tt class="docutils literal"><span class="pre">role=fg/bg,option,option</span></tt></li>
</ul>
<p>where <tt class="docutils literal"><span class="pre">role</span></tt> is the name of a valid color role, <tt class="docutils literal"><span class="pre">fg</span></tt> is the
foreground color, <tt class="docutils literal"><span class="pre">bg</span></tt> is the background color and each <tt class="docutils literal"><span class="pre">option</span></tt>
is one of the color modifying options. Multiple color specifications
are then separated by semicolon. For example:</p>
<div class="highlight-python"><pre>export DJANGO_COLORS="error=yellow/blue,blink;notice=magenta"</pre>
</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-python"><pre>export DJANGO_COLORS="light;error=yellow/blue,blink;notice=magenta"</pre>
</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>
<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 <tt class="docutils literal"><span class="pre">extras/django_bash_completion</span></tt> in the Django
distribution. It enables tab-completion of <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> and
<tt class="docutils literal"><span class="pre">manage.py</span></tt> commands, so you can, for instance...</p>
<ul class="simple">
<li>Type <tt class="docutils literal"><span class="pre">django-admin.py</span></tt>.</li>
<li>Press [TAB] to see all available options.</li>
<li>Type <tt class="docutils literal"><span class="pre">sql</span></tt>, then [TAB], to see all available options whose names start
with <tt class="docutils literal"><span class="pre">sql</span></tt>.</li>
</ul>
<p>See <a class="reference internal" href="../howto/custom-management-commands.html"><em>Writing custom django-admin commands</em></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">
<tt class="descclassname">django.core.management.</tt><tt class="descname">call_command</tt>(<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 <tt class="docutils literal"><span class="pre">call_command</span></tt>.</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">name</span></tt></dt>
<dd>the name of the command to call.</dd>
<dt><tt class="docutils literal"><span class="pre">*args</span></tt></dt>
<dd>a list of arguments accepted by the command.</dd>
<dt><tt class="docutils literal"><span class="pre">**options</span></tt></dt>
<dd>named options accepted on the command-line.</dd>
</dl>
<p>Examples:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.core</span> <span class="kn">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="s">&#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="bp">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="s">&#39;loaddata&#39;</span><span class="p">,</span> <span class="s">&#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 <tt class="docutils literal"><span class="pre">True</span></tt> or <tt class="docutils literal"><span class="pre">False</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">management</span><span class="o">.</span><span class="n">call_command</span><span class="p">(</span><span class="s">&#39;dumpdata&#39;</span><span class="p">,</span> <span class="n">use_natural_keys</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
</pre></div>
</div>
<p>Command options which take multiple options are passed a list:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">management</span><span class="o">.</span><span class="n">call_command</span><span class="p">(</span><span class="s">&#39;dumpdata&#39;</span><span class="p">,</span> <span class="n">exclude</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;contenttypes&#39;</span><span class="p">,</span> <span class="s">&#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 <tt class="docutils literal"><span class="pre">stdout</span></tt> and <tt class="docutils literal"><span class="pre">stderr</span></tt> options. For example, you could write:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s">&#39;/tmp/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="s">&#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">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">django-admin.py 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">check</a></li>
<li><a class="reference internal" href="#cleanup">cleanup</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-appname-appname-appname-model">dumpdata &lt;appname appname appname.Model ...&gt;</a></li>
<li><a class="reference internal" href="#flush">flush</a><ul>
<li><a class="reference internal" href="#no-initial-data"><tt class="docutils literal"><span class="pre">--no-initial-data</span></tt></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="#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="#sql-appname-appname">sql &lt;appname appname ...&gt;</a></li>
<li><a class="reference internal" href="#sqlall-appname-appname">sqlall &lt;appname appname ...&gt;</a></li>
<li><a class="reference internal" href="#sqlclear-appname-appname">sqlclear &lt;appname appname ...&gt;</a></li>
<li><a class="reference internal" href="#sqlcustom-appname-appname">sqlcustom &lt;appname appname ...&gt;</a></li>
<li><a class="reference internal" href="#sqldropindexes-appname-appname">sqldropindexes &lt;appname appname ...&gt;</a></li>
<li><a class="reference internal" href="#sqlflush">sqlflush</a></li>
<li><a class="reference internal" href="#sqlindexes-appname-appname">sqlindexes &lt;appname appname ...&gt;</a></li>
<li><a class="reference internal" href="#sqlsequencereset-appname-appname">sqlsequencereset &lt;appname appname ...&gt;</a></li>
<li><a class="reference internal" href="#startapp-appname-destination">startapp &lt;appname&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><ul>
<li><a class="reference internal" href="#id1"><tt class="docutils literal"><span class="pre">--no-initial-data</span></tt></a></li>
</ul>
</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"><tt class="docutils literal"><span class="pre">django.contrib.auth</span></tt></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"><tt class="docutils literal"><span class="pre">django.contrib.gis</span></tt></a><ul>
<li><a class="reference internal" href="#ogrinspect">ogrinspect</a></li>
</ul>
</li>
<li><a class="reference internal" href="#django-contrib-sessions"><tt class="docutils literal"><span class="pre">django.contrib.sessions</span></tt></a><ul>
<li><a class="reference internal" href="#clearsessions">clearsessions</a></li>
</ul>
</li>
<li><a class="reference internal" href="#django-contrib-sitemaps"><tt class="docutils literal"><span class="pre">django.contrib.sitemaps</span></tt></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"><tt class="docutils literal"><span class="pre">django.contrib.staticfiles</span></tt></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.6.7 documentation</a>
        
          <ul><li><a href="index.html">API Reference</a>
        
        <ul><li>django-admin.py and manage.py</li></ul>
        </li></ul>
      </li>
  </ul>  

  <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 id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Sep 26, 2014</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>