Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > 481c2de1450e70fa8fdc1e3abf72606b > files > 870

python-django-doc-1.11.20-1.mga7.noarch.rpm


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

<html xmlns="http://www.w3.org/1999/xhtml" lang="">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Model Meta options &#8212; Django 1.11.20 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" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></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>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Model instance reference" href="instances.html" />
    <link rel="prev" title="Model class reference" href="class.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.11.20 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="class.html" title="Model class reference">previous</a>
     |
    <a href="../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="instances.html" title="Model instance reference">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-models-options">
            
  <div class="section" id="s-model-meta-options">
<span id="model-meta-options"></span><h1>Model <code class="docutils literal notranslate"><span class="pre">Meta</span></code> options<a class="headerlink" href="#model-meta-options" title="Permalink to this headline">¶</a></h1>
<p>This document explains all the possible <a class="reference internal" href="../../topics/db/models.html#meta-options"><span class="std std-ref">metadata options</span></a> that you can give your model in its internal
<code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">Meta</span></code>.</p>
<div class="section" id="s-available-meta-options">
<span id="available-meta-options"></span><h2>Available <code class="docutils literal notranslate"><span class="pre">Meta</span></code> options<a class="headerlink" href="#available-meta-options" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-abstract">
<span id="abstract"></span><h3><code class="docutils literal notranslate"><span class="pre">abstract</span></code><a class="headerlink" href="#abstract" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.abstract">
<code class="descclassname">Options.</code><code class="descname">abstract</code><a class="headerlink" href="#django.db.models.Options.abstract" title="Permalink to this definition">¶</a></dt>
<dd><p>If <code class="docutils literal notranslate"><span class="pre">abstract</span> <span class="pre">=</span> <span class="pre">True</span></code>, this model will be an
<a class="reference internal" href="../../topics/db/models.html#abstract-base-classes"><span class="std std-ref">abstract base class</span></a>.</p>
</dd></dl>

</div>
<div class="section" id="s-app-label">
<span id="app-label"></span><h3><code class="docutils literal notranslate"><span class="pre">app_label</span></code><a class="headerlink" href="#app-label" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.app_label">
<code class="descclassname">Options.</code><code class="descname">app_label</code><a class="headerlink" href="#django.db.models.Options.app_label" title="Permalink to this definition">¶</a></dt>
<dd><p>If a model is defined outside of an application in
<a class="reference internal" href="../settings.html#std:setting-INSTALLED_APPS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">INSTALLED_APPS</span></code></a>, it must declare which app it belongs to:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">app_label</span> <span class="o">=</span> <span class="s1">&#39;myapp&#39;</span>
</pre></div>
</div>
<p>If you want to represent a model with the format <code class="docutils literal notranslate"><span class="pre">app_label.object_name</span></code>
or <code class="docutils literal notranslate"><span class="pre">app_label.model_name</span></code> you can use <code class="docutils literal notranslate"><span class="pre">model._meta.label</span></code>
or <code class="docutils literal notranslate"><span class="pre">model._meta.label_lower</span></code> respectively.</p>
</dd></dl>

</div>
<div class="section" id="s-base-manager-name">
<span id="base-manager-name"></span><h3><code class="docutils literal notranslate"><span class="pre">base_manager_name</span></code><a class="headerlink" href="#base-manager-name" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.base_manager_name">
<code class="descclassname">Options.</code><code class="descname">base_manager_name</code><a class="headerlink" href="#django.db.models.Options.base_manager_name" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.10.</span> </div>
<p>The name of the manager to use for the model’s
<a class="reference internal" href="../../topics/db/managers.html#django.db.models.Model._base_manager" title="django.db.models.Model._base_manager"><code class="xref py py-attr docutils literal notranslate"><span class="pre">_base_manager</span></code></a>.</p>
</dd></dl>

</div>
<div class="section" id="s-db-table">
<span id="db-table"></span><h3><code class="docutils literal notranslate"><span class="pre">db_table</span></code><a class="headerlink" href="#db-table" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.db_table">
<code class="descclassname">Options.</code><code class="descname">db_table</code><a class="headerlink" href="#django.db.models.Options.db_table" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the database table to use for the model:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">db_table</span> <span class="o">=</span> <span class="s1">&#39;music_album&#39;</span>
</pre></div>
</div>
</dd></dl>

<div class="section" id="s-table-names">
<span id="s-id1"></span><span id="table-names"></span><span id="id1"></span><h4>Table names<a class="headerlink" href="#table-names" title="Permalink to this headline">¶</a></h4>
<p>To save you time, Django automatically derives the name of the database table
from the name of your model class and the app that contains it. A model’s
database table name is constructed by joining the model’s “app label” – the
name you used in <a class="reference internal" href="../django-admin.html#django-admin-startapp"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">manage.py</span> <span class="pre">startapp</span></code></a> – to the model’s
class name, with an underscore between them.</p>
<p>For example, if you have an app <code class="docutils literal notranslate"><span class="pre">bookstore</span></code> (as created by
<code class="docutils literal notranslate"><span class="pre">manage.py</span> <span class="pre">startapp</span> <span class="pre">bookstore</span></code>), a model defined as <code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">Book</span></code> will have
a database table named <code class="docutils literal notranslate"><span class="pre">bookstore_book</span></code>.</p>
<p>To override the database table name, use the <code class="docutils literal notranslate"><span class="pre">db_table</span></code> parameter in
<code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">Meta</span></code>.</p>
<p>If your database table name is an SQL reserved word, or contains characters that
aren’t allowed in Python variable names – notably, the hyphen – that’s OK.
Django quotes column and table names behind the scenes.</p>
<div class="admonition-use-lowercase-table-names-for-mysql admonition">
<p class="first admonition-title">Use lowercase table names for MySQL</p>
<p class="last">It is strongly advised that you use lowercase table names when you override
the table name via <code class="docutils literal notranslate"><span class="pre">db_table</span></code>, particularly if you are using the MySQL
backend. See the <a class="reference internal" href="../databases.html#mysql-notes"><span class="std std-ref">MySQL notes</span></a> for more details.</p>
</div>
<div class="admonition-table-name-quoting-for-oracle admonition">
<p class="first admonition-title">Table name quoting for Oracle</p>
<p>In order to meet the 30-char limitation Oracle has on table names,
and match the usual conventions for Oracle databases, Django may shorten
table names and turn them all-uppercase. To prevent such transformations,
use a quoted name as the value for <code class="docutils literal notranslate"><span class="pre">db_table</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">db_table</span> <span class="o">=</span> <span class="s1">&#39;&quot;name_left_in_lowercase&quot;&#39;</span>
</pre></div>
</div>
<p class="last">Such quoted names can also be used with Django’s other supported database
backends; except for Oracle, however, the quotes have no effect. See the
<a class="reference internal" href="../databases.html#oracle-notes"><span class="std std-ref">Oracle notes</span></a> for more details.</p>
</div>
</div>
</div>
<div class="section" id="s-db-tablespace">
<span id="db-tablespace"></span><h3><code class="docutils literal notranslate"><span class="pre">db_tablespace</span></code><a class="headerlink" href="#db-tablespace" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.db_tablespace">
<code class="descclassname">Options.</code><code class="descname">db_tablespace</code><a class="headerlink" href="#django.db.models.Options.db_tablespace" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the <a class="reference internal" href="../../topics/db/tablespaces.html"><span class="doc">database tablespace</span></a> to use
for this model. The default is the project’s <a class="reference internal" href="../settings.html#std:setting-DEFAULT_TABLESPACE"><code class="xref std std-setting docutils literal notranslate"><span class="pre">DEFAULT_TABLESPACE</span></code></a>
setting, if set. If the backend doesn’t support tablespaces, this option is
ignored.</p>
</dd></dl>

</div>
<div class="section" id="s-default-manager-name">
<span id="default-manager-name"></span><h3><code class="docutils literal notranslate"><span class="pre">default_manager_name</span></code><a class="headerlink" href="#default-manager-name" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.default_manager_name">
<code class="descclassname">Options.</code><code class="descname">default_manager_name</code><a class="headerlink" href="#django.db.models.Options.default_manager_name" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.10.</span> </div>
<p>The name of the manager to use for the model’s
<a class="reference internal" href="../../topics/db/managers.html#django.db.models.Model._default_manager" title="django.db.models.Model._default_manager"><code class="xref py py-attr docutils literal notranslate"><span class="pre">_default_manager</span></code></a>.</p>
</dd></dl>

</div>
<div class="section" id="s-default-related-name">
<span id="default-related-name"></span><h3><code class="docutils literal notranslate"><span class="pre">default_related_name</span></code><a class="headerlink" href="#default-related-name" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.default_related_name">
<code class="descclassname">Options.</code><code class="descname">default_related_name</code><a class="headerlink" href="#django.db.models.Options.default_related_name" title="Permalink to this definition">¶</a></dt>
<dd><p>The name that will be used by default for the relation from a related object
back to this one. The default is <code class="docutils literal notranslate"><span class="pre">&lt;model_name&gt;_set</span></code>.</p>
<p>This option also sets <a class="reference internal" href="fields.html#django.db.models.ForeignKey.related_query_name" title="django.db.models.ForeignKey.related_query_name"><code class="xref py py-attr docutils literal notranslate"><span class="pre">related_query_name</span></code></a>.</p>
<p>As the reverse name for a field should be unique, be careful if you intend
to subclass your model. To work around name collisions, part of the name
should contain <code class="docutils literal notranslate"><span class="pre">'%(app_label)s'</span></code> and <code class="docutils literal notranslate"><span class="pre">'%(model_name)s'</span></code>, which are
replaced respectively by the name of the application the model is in,
and the name of the model, both lowercased. See the paragraph on
<a class="reference internal" href="../../topics/db/models.html#abstract-related-name"><span class="std std-ref">related names for abstract models</span></a>.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 1.10: </span>This attribute now affects <code class="docutils literal notranslate"><span class="pre">related_query_name</span></code>. The old query lookup
name is deprecated:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.db</span> <span class="k">import</span> <span class="n">models</span>

<span class="k">class</span> <span class="nc">Foo</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="k">pass</span>

<span class="k">class</span> <span class="nc">Bar</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">foo</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">(</span><span class="n">Foo</span><span class="p">)</span>

    <span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
        <span class="n">default_related_name</span> <span class="o">=</span> <span class="s1">&#39;bars&#39;</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">bar</span> <span class="o">=</span> <span class="n">Bar</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">pk</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># Using model name &quot;bar&quot; as lookup string is deprecated.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Foo</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">bar</span><span class="o">=</span><span class="n">bar</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># You should use default_related_name &quot;bars&quot;.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Foo</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">bars</span><span class="o">=</span><span class="n">bar</span><span class="p">)</span>
</pre></div>
</div>
</div>
</dd></dl>

</div>
<div class="section" id="s-get-latest-by">
<span id="get-latest-by"></span><h3><code class="docutils literal notranslate"><span class="pre">get_latest_by</span></code><a class="headerlink" href="#get-latest-by" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.get_latest_by">
<code class="descclassname">Options.</code><code class="descname">get_latest_by</code><a class="headerlink" href="#django.db.models.Options.get_latest_by" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of an orderable field in the model, typically a <a class="reference internal" href="fields.html#django.db.models.DateField" title="django.db.models.DateField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateField</span></code></a>,
<a class="reference internal" href="fields.html#django.db.models.DateTimeField" title="django.db.models.DateTimeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateTimeField</span></code></a>, or <a class="reference internal" href="fields.html#django.db.models.IntegerField" title="django.db.models.IntegerField"><code class="xref py py-class docutils literal notranslate"><span class="pre">IntegerField</span></code></a>. This specifies the default
field to use in your model <a class="reference internal" href="../../topics/db/managers.html#django.db.models.Manager" title="django.db.models.Manager"><code class="xref py py-class docutils literal notranslate"><span class="pre">Manager</span></code></a>’s
<a class="reference internal" href="querysets.html#django.db.models.query.QuerySet.latest" title="django.db.models.query.QuerySet.latest"><code class="xref py py-meth docutils literal notranslate"><span class="pre">latest()</span></code></a> and
<a class="reference internal" href="querysets.html#django.db.models.query.QuerySet.earliest" title="django.db.models.query.QuerySet.earliest"><code class="xref py py-meth docutils literal notranslate"><span class="pre">earliest()</span></code></a> methods.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">get_latest_by</span> <span class="o">=</span> <span class="s2">&quot;order_date&quot;</span>
</pre></div>
</div>
<p>See the <a class="reference internal" href="querysets.html#django.db.models.query.QuerySet.latest" title="django.db.models.query.QuerySet.latest"><code class="xref py py-meth docutils literal notranslate"><span class="pre">latest()</span></code></a> docs for more.</p>
</dd></dl>

</div>
<div class="section" id="s-managed">
<span id="managed"></span><h3><code class="docutils literal notranslate"><span class="pre">managed</span></code><a class="headerlink" href="#managed" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.managed">
<code class="descclassname">Options.</code><code class="descname">managed</code><a class="headerlink" href="#django.db.models.Options.managed" title="Permalink to this definition">¶</a></dt>
<dd><p>Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>, meaning Django will create the appropriate database
tables in <a class="reference internal" href="../django-admin.html#django-admin-migrate"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">migrate</span></code></a> or as part of migrations and remove them as
part of a <a class="reference internal" href="../django-admin.html#django-admin-flush"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">flush</span></code></a> management command. That is, Django
<em>manages</em> the database tables’ lifecycles.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">False</span></code>, no database table creation or deletion operations will be
performed for this model. This is useful if the model represents an existing
table or a database view that has been created by some other means. This is
the <em>only</em> difference when <code class="docutils literal notranslate"><span class="pre">managed=False</span></code>. All other aspects of
model handling are exactly the same as normal. This includes</p>
<ol class="arabic">
<li><p class="first">Adding an automatic primary key field to the model if you don’t
declare it.  To avoid confusion for later code readers, it’s
recommended to specify all the columns from the database table you
are modeling when using unmanaged models.</p>
</li>
<li><p class="first">If a model with <code class="docutils literal notranslate"><span class="pre">managed=False</span></code> contains a
<a class="reference internal" href="fields.html#django.db.models.ManyToManyField" title="django.db.models.ManyToManyField"><code class="xref py py-class docutils literal notranslate"><span class="pre">ManyToManyField</span></code></a> that points to another
unmanaged model, then the intermediate table for the many-to-many
join will also not be created. However, the intermediary table
between one managed and one unmanaged model <em>will</em> be created.</p>
<p>If you need to change this default behavior, create the intermediary
table as an explicit model (with <code class="docutils literal notranslate"><span class="pre">managed</span></code> set as needed) and use
the <a class="reference internal" href="fields.html#django.db.models.ManyToManyField.through" title="django.db.models.ManyToManyField.through"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ManyToManyField.through</span></code></a> attribute to make the relation
use your custom model.</p>
</li>
</ol>
<p>For tests involving models with <code class="docutils literal notranslate"><span class="pre">managed=False</span></code>, it’s up to you to ensure
the correct tables are created as part of the test setup.</p>
<p>If you’re interested in changing the Python-level behavior of a model class,
you <em>could</em> use <code class="docutils literal notranslate"><span class="pre">managed=False</span></code> and create a copy of an existing model.
However, there’s a better approach for that situation: <a class="reference internal" href="../../topics/db/models.html#proxy-models"><span class="std std-ref">Proxy models</span></a>.</p>
</dd></dl>

</div>
<div class="section" id="s-order-with-respect-to">
<span id="order-with-respect-to"></span><h3><code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code><a class="headerlink" href="#order-with-respect-to" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.order_with_respect_to">
<code class="descclassname">Options.</code><code class="descname">order_with_respect_to</code><a class="headerlink" href="#django.db.models.Options.order_with_respect_to" title="Permalink to this definition">¶</a></dt>
<dd><p>Makes this object orderable with respect to the given field, usually a
<code class="docutils literal notranslate"><span class="pre">ForeignKey</span></code>. This can be used to make related objects orderable with
respect to a parent object. For example, if an <code class="docutils literal notranslate"><span class="pre">Answer</span></code> relates to a
<code class="docutils literal notranslate"><span class="pre">Question</span></code> object, and a question has more than one answer, and the order
of answers matters, you’d do this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.db</span> <span class="k">import</span> <span class="n">models</span>

<span class="k">class</span> <span class="nc">Question</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">text</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">TextField</span><span class="p">()</span>
    <span class="c1"># ...</span>

<span class="k">class</span> <span class="nc">Answer</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">question</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">(</span><span class="n">Question</span><span class="p">,</span> <span class="n">on_delete</span><span class="o">=</span><span class="n">models</span><span class="o">.</span><span class="n">CASCADE</span><span class="p">)</span>
    <span class="c1"># ...</span>

    <span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
        <span class="n">order_with_respect_to</span> <span class="o">=</span> <span class="s1">&#39;question&#39;</span>
</pre></div>
</div>
<p>When <code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code> is set, two additional methods are provided to
retrieve and to set the order of the related objects: <code class="docutils literal notranslate"><span class="pre">get_RELATED_order()</span></code>
and <code class="docutils literal notranslate"><span class="pre">set_RELATED_order()</span></code>, where <code class="docutils literal notranslate"><span class="pre">RELATED</span></code> is the lowercased model name. For
example, assuming that a <code class="docutils literal notranslate"><span class="pre">Question</span></code> object has multiple related <code class="docutils literal notranslate"><span class="pre">Answer</span></code>
objects, the list returned contains the primary keys of the related <code class="docutils literal notranslate"><span class="pre">Answer</span></code>
objects:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">question</span> <span class="o">=</span> <span class="n">Question</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">question</span><span class="o">.</span><span class="n">get_answer_order</span><span class="p">()</span>
<span class="go">[1, 2, 3]</span>
</pre></div>
</div>
<p>The order of a <code class="docutils literal notranslate"><span class="pre">Question</span></code> object’s related <code class="docutils literal notranslate"><span class="pre">Answer</span></code> objects can be set by
passing in a list of <code class="docutils literal notranslate"><span class="pre">Answer</span></code> primary keys:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">question</span><span class="o">.</span><span class="n">set_answer_order</span><span class="p">([</span><span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">])</span>
</pre></div>
</div>
<p>The related objects also get two methods, <code class="docutils literal notranslate"><span class="pre">get_next_in_order()</span></code> and
<code class="docutils literal notranslate"><span class="pre">get_previous_in_order()</span></code>, which can be used to access those objects in their
proper order. Assuming the <code class="docutils literal notranslate"><span class="pre">Answer</span></code> objects are ordered by <code class="docutils literal notranslate"><span class="pre">id</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">answer</span> <span class="o">=</span> <span class="n">Answer</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">answer</span><span class="o">.</span><span class="n">get_next_in_order</span><span class="p">()</span>
<span class="go">&lt;Answer: 3&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">answer</span><span class="o">.</span><span class="n">get_previous_in_order</span><span class="p">()</span>
<span class="go">&lt;Answer: 1&gt;</span>
</pre></div>
</div>
</dd></dl>

<div class="admonition-order-with-respect-to-implicitly-sets-the-ordering-option admonition">
<p class="first admonition-title"><code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code> implicitly sets the <code class="docutils literal notranslate"><span class="pre">ordering</span></code> option</p>
<p class="last">Internally, <code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code> adds an additional field/database
column named <code class="docutils literal notranslate"><span class="pre">_order</span></code> and sets the model’s <a class="reference internal" href="#django.db.models.Options.ordering" title="django.db.models.Options.ordering"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ordering</span></code></a>
option to this field. Consequently, <code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code> and
<code class="docutils literal notranslate"><span class="pre">ordering</span></code> cannot be used together, and the ordering added by
<code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code> will apply whenever you obtain a list of objects
of this model.</p>
</div>
<div class="admonition-changing-order-with-respect-to admonition">
<p class="first admonition-title">Changing <code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code></p>
<p class="last">Because <code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code> adds a new database column, be sure to
make and apply the appropriate migrations if you add or change
<code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code> after your initial <a class="reference internal" href="../django-admin.html#django-admin-migrate"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">migrate</span></code></a>.</p>
</div>
</div>
<div class="section" id="s-ordering">
<span id="ordering"></span><h3><code class="docutils literal notranslate"><span class="pre">ordering</span></code><a class="headerlink" href="#ordering" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.ordering">
<code class="descclassname">Options.</code><code class="descname">ordering</code><a class="headerlink" href="#django.db.models.Options.ordering" title="Permalink to this definition">¶</a></dt>
<dd><p>The default ordering for the object, for use when obtaining lists of objects:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ordering</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;-order_date&#39;</span><span class="p">]</span>
</pre></div>
</div>
<p>This is a tuple or list of strings. Each string is a field name with an optional
“-” prefix, which indicates descending order. Fields without a leading “-” will
be ordered ascending. Use the string “?” to order randomly.</p>
<p>For example, to order by a <code class="docutils literal notranslate"><span class="pre">pub_date</span></code> field ascending, use this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ordering</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;pub_date&#39;</span><span class="p">]</span>
</pre></div>
</div>
<p>To order by <code class="docutils literal notranslate"><span class="pre">pub_date</span></code> descending, use this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ordering</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;-pub_date&#39;</span><span class="p">]</span>
</pre></div>
</div>
<p>To order by <code class="docutils literal notranslate"><span class="pre">pub_date</span></code> descending, then by <code class="docutils literal notranslate"><span class="pre">author</span></code> ascending, use this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ordering</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;-pub_date&#39;</span><span class="p">,</span> <span class="s1">&#39;author&#39;</span><span class="p">]</span>
</pre></div>
</div>
<p>Default ordering also affects <a class="reference internal" href="../../topics/db/aggregation.html#aggregation-ordering-interaction"><span class="std std-ref">aggregation queries</span></a>.</p>
</dd></dl>

<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p>Ordering is not a free operation. Each field you add to the ordering
incurs a cost to your database. Each foreign key you add will
implicitly include all of its default orderings as well.</p>
<p class="last">If a query doesn’t have an ordering specified, results are returned from
the database in an unspecified order. A particular ordering is guaranteed
only when ordering by a set of fields that uniquely identify each object in
the results. For example, if a <code class="docutils literal notranslate"><span class="pre">name</span></code> field isn’t unique, ordering by it
won’t guarantee objects with the same name always appear in the same order.</p>
</div>
</div>
<div class="section" id="s-permissions">
<span id="permissions"></span><h3><code class="docutils literal notranslate"><span class="pre">permissions</span></code><a class="headerlink" href="#permissions" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.permissions">
<code class="descclassname">Options.</code><code class="descname">permissions</code><a class="headerlink" href="#django.db.models.Options.permissions" title="Permalink to this definition">¶</a></dt>
<dd><p>Extra permissions to enter into the permissions table when creating this object.
Add, delete and change permissions are automatically created for each
model. This example specifies an extra permission, <code class="docutils literal notranslate"><span class="pre">can_deliver_pizzas</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">permissions</span> <span class="o">=</span> <span class="p">((</span><span class="s2">&quot;can_deliver_pizzas&quot;</span><span class="p">,</span> <span class="s2">&quot;Can deliver pizzas&quot;</span><span class="p">),)</span>
</pre></div>
</div>
<p>This is a list or tuple of 2-tuples in the format <code class="docutils literal notranslate"><span class="pre">(permission_code,</span>
<span class="pre">human_readable_permission_name)</span></code>.</p>
</dd></dl>

</div>
<div class="section" id="s-default-permissions">
<span id="default-permissions"></span><h3><code class="docutils literal notranslate"><span class="pre">default_permissions</span></code><a class="headerlink" href="#default-permissions" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.default_permissions">
<code class="descclassname">Options.</code><code class="descname">default_permissions</code><a class="headerlink" href="#django.db.models.Options.default_permissions" title="Permalink to this definition">¶</a></dt>
<dd><p>Defaults to <code class="docutils literal notranslate"><span class="pre">('add',</span> <span class="pre">'change',</span> <span class="pre">'delete')</span></code>. You may customize this list,
for example, by setting this to an empty list if your app doesn’t require
any of the default permissions. It must be specified on the model before
the model is created by <a class="reference internal" href="../django-admin.html#django-admin-migrate"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">migrate</span></code></a> in order to prevent any omitted
permissions from being created.</p>
</dd></dl>

</div>
<div class="section" id="s-proxy">
<span id="proxy"></span><h3><code class="docutils literal notranslate"><span class="pre">proxy</span></code><a class="headerlink" href="#proxy" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.proxy">
<code class="descclassname">Options.</code><code class="descname">proxy</code><a class="headerlink" href="#django.db.models.Options.proxy" title="Permalink to this definition">¶</a></dt>
<dd><p>If <code class="docutils literal notranslate"><span class="pre">proxy</span> <span class="pre">=</span> <span class="pre">True</span></code>, a model which subclasses another model will be treated as
a <a class="reference internal" href="../../topics/db/models.html#proxy-models"><span class="std std-ref">proxy model</span></a>.</p>
</dd></dl>

</div>
<div class="section" id="s-required-db-features">
<span id="required-db-features"></span><h3><code class="docutils literal notranslate"><span class="pre">required_db_features</span></code><a class="headerlink" href="#required-db-features" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.required_db_features">
<code class="descclassname">Options.</code><code class="descname">required_db_features</code><a class="headerlink" href="#django.db.models.Options.required_db_features" title="Permalink to this definition">¶</a></dt>
<dd><p>List of database features that the current connection should have so that
the model is considered during the migration phase. For example, if you set
this list to <code class="docutils literal notranslate"><span class="pre">['gis_enabled']</span></code>, the model will only be synchronized on
GIS-enabled databases. It’s also useful to skip some models when testing
with several database backends. Avoid relations between models that may or
may not be created as the ORM doesn’t handle this.</p>
</dd></dl>

</div>
<div class="section" id="s-required-db-vendor">
<span id="required-db-vendor"></span><h3><code class="docutils literal notranslate"><span class="pre">required_db_vendor</span></code><a class="headerlink" href="#required-db-vendor" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.required_db_vendor">
<code class="descclassname">Options.</code><code class="descname">required_db_vendor</code><a class="headerlink" href="#django.db.models.Options.required_db_vendor" title="Permalink to this definition">¶</a></dt>
<dd><p>Name of a supported database vendor that this model is specific to. Current
built-in vendor names are: <code class="docutils literal notranslate"><span class="pre">sqlite</span></code>, <code class="docutils literal notranslate"><span class="pre">postgresql</span></code>, <code class="docutils literal notranslate"><span class="pre">mysql</span></code>,
<code class="docutils literal notranslate"><span class="pre">oracle</span></code>. If this attribute is not empty and the current connection vendor
doesn’t match it, the model will not be synchronized.</p>
</dd></dl>

</div>
<div class="section" id="s-select-on-save">
<span id="select-on-save"></span><h3><code class="docutils literal notranslate"><span class="pre">select_on_save</span></code><a class="headerlink" href="#select-on-save" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.select_on_save">
<code class="descclassname">Options.</code><code class="descname">select_on_save</code><a class="headerlink" href="#django.db.models.Options.select_on_save" title="Permalink to this definition">¶</a></dt>
<dd><p>Determines if Django will use the pre-1.6
<a class="reference internal" href="instances.html#django.db.models.Model.save" title="django.db.models.Model.save"><code class="xref py py-meth docutils literal notranslate"><span class="pre">django.db.models.Model.save()</span></code></a> algorithm. The old algorithm
uses <code class="docutils literal notranslate"><span class="pre">SELECT</span></code> to determine if there is an existing row to be updated.
The new algorithm tries an <code class="docutils literal notranslate"><span class="pre">UPDATE</span></code> directly. In some rare cases the
<code class="docutils literal notranslate"><span class="pre">UPDATE</span></code> of an existing row isn’t visible to Django. An example is the
PostgreSQL <code class="docutils literal notranslate"><span class="pre">ON</span> <span class="pre">UPDATE</span></code> trigger which returns <code class="docutils literal notranslate"><span class="pre">NULL</span></code>. In such cases the
new algorithm will end up doing an <code class="docutils literal notranslate"><span class="pre">INSERT</span></code> even when a row exists in
the database.</p>
<p>Usually there is no need to set this attribute. The default is
<code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
<p>See <a class="reference internal" href="instances.html#django.db.models.Model.save" title="django.db.models.Model.save"><code class="xref py py-meth docutils literal notranslate"><span class="pre">django.db.models.Model.save()</span></code></a> for more about the old and
new saving algorithm.</p>
</dd></dl>

</div>
<div class="section" id="s-indexes">
<span id="indexes"></span><h3><code class="docutils literal notranslate"><span class="pre">indexes</span></code><a class="headerlink" href="#indexes" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.indexes">
<code class="descclassname">Options.</code><code class="descname">indexes</code><a class="headerlink" href="#django.db.models.Options.indexes" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.11.</span> </div>
<p>A list of <a class="reference internal" href="indexes.html"><span class="doc">indexes</span></a> that you want to define on
the model:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.db</span> <span class="k">import</span> <span class="n">models</span>

<span class="k">class</span> <span class="nc">Customer</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">first_name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
    <span class="n">last_name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>

    <span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
        <span class="n">indexes</span> <span class="o">=</span> <span class="p">[</span>
            <span class="n">models</span><span class="o">.</span><span class="n">Index</span><span class="p">(</span><span class="n">fields</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;last_name&#39;</span><span class="p">,</span> <span class="s1">&#39;first_name&#39;</span><span class="p">]),</span>
            <span class="n">models</span><span class="o">.</span><span class="n">Index</span><span class="p">(</span><span class="n">fields</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;first_name&#39;</span><span class="p">],</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;first_name_idx&#39;</span><span class="p">),</span>
        <span class="p">]</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="s-unique-together">
<span id="unique-together"></span><h3><code class="docutils literal notranslate"><span class="pre">unique_together</span></code><a class="headerlink" href="#unique-together" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.unique_together">
<code class="descclassname">Options.</code><code class="descname">unique_together</code><a class="headerlink" href="#django.db.models.Options.unique_together" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets of field names that, taken together, must be unique:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">unique_together</span> <span class="o">=</span> <span class="p">((</span><span class="s2">&quot;driver&quot;</span><span class="p">,</span> <span class="s2">&quot;restaurant&quot;</span><span class="p">),)</span>
</pre></div>
</div>
<p>This is a tuple of tuples that must be unique when considered together.
It’s used in the Django admin and is enforced at the database level (i.e., the
appropriate <code class="docutils literal notranslate"><span class="pre">UNIQUE</span></code> statements are included in the <code class="docutils literal notranslate"><span class="pre">CREATE</span> <span class="pre">TABLE</span></code>
statement).</p>
<p>For convenience, unique_together can be a single tuple when dealing with a single
set of fields:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">unique_together</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;driver&quot;</span><span class="p">,</span> <span class="s2">&quot;restaurant&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>A <a class="reference internal" href="fields.html#django.db.models.ManyToManyField" title="django.db.models.ManyToManyField"><code class="xref py py-class docutils literal notranslate"><span class="pre">ManyToManyField</span></code></a> cannot be included in
unique_together. (It’s not clear what that would even mean!) If you
need to validate uniqueness related to a
<a class="reference internal" href="fields.html#django.db.models.ManyToManyField" title="django.db.models.ManyToManyField"><code class="xref py py-class docutils literal notranslate"><span class="pre">ManyToManyField</span></code></a>, try using a signal or
an explicit <a class="reference internal" href="fields.html#django.db.models.ManyToManyField.through" title="django.db.models.ManyToManyField.through"><code class="xref py py-attr docutils literal notranslate"><span class="pre">through</span></code></a> model.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">ValidationError</span></code> raised during model validation when the constraint
is violated has the <code class="docutils literal notranslate"><span class="pre">unique_together</span></code> error code.</p>
</dd></dl>

</div>
<div class="section" id="s-index-together">
<span id="index-together"></span><h3><code class="docutils literal notranslate"><span class="pre">index_together</span></code><a class="headerlink" href="#index-together" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.index_together">
<code class="descclassname">Options.</code><code class="descname">index_together</code><a class="headerlink" href="#django.db.models.Options.index_together" title="Permalink to this definition">¶</a></dt>
<dd><div class="admonition-use-the-attr-options-indexes-option-instead admonition">
<p class="first admonition-title">Use the <a class="reference internal" href="#django.db.models.Options.indexes" title="django.db.models.Options.indexes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">indexes</span></code></a> option instead.</p>
<p class="last">The newer <a class="reference internal" href="#django.db.models.Options.indexes" title="django.db.models.Options.indexes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">indexes</span></code></a> option provides more functionality
than <code class="docutils literal notranslate"><span class="pre">index_together</span></code>. <code class="docutils literal notranslate"><span class="pre">index_together</span></code> may be deprecated in the
future.</p>
</div>
<p>Sets of field names that, taken together, are indexed:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">index_together</span> <span class="o">=</span> <span class="p">[</span>
    <span class="p">[</span><span class="s2">&quot;pub_date&quot;</span><span class="p">,</span> <span class="s2">&quot;deadline&quot;</span><span class="p">],</span>
<span class="p">]</span>
</pre></div>
</div>
<p>This list of fields will be indexed together (i.e. the appropriate
<code class="docutils literal notranslate"><span class="pre">CREATE</span> <span class="pre">INDEX</span></code> statement will be issued.)</p>
<p>For convenience, <code class="docutils literal notranslate"><span class="pre">index_together</span></code> can be a single list when dealing with a single
set of fields:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">index_together</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;pub_date&quot;</span><span class="p">,</span> <span class="s2">&quot;deadline&quot;</span><span class="p">]</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="s-verbose-name">
<span id="verbose-name"></span><h3><code class="docutils literal notranslate"><span class="pre">verbose_name</span></code><a class="headerlink" href="#verbose-name" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.verbose_name">
<code class="descclassname">Options.</code><code class="descname">verbose_name</code><a class="headerlink" href="#django.db.models.Options.verbose_name" title="Permalink to this definition">¶</a></dt>
<dd><p>A human-readable name for the object, singular:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">verbose_name</span> <span class="o">=</span> <span class="s2">&quot;pizza&quot;</span>
</pre></div>
</div>
<p>If this isn’t given, Django will use a munged version of the class name:
<code class="docutils literal notranslate"><span class="pre">CamelCase</span></code> becomes <code class="docutils literal notranslate"><span class="pre">camel</span> <span class="pre">case</span></code>.</p>
</dd></dl>

</div>
<div class="section" id="s-verbose-name-plural">
<span id="verbose-name-plural"></span><h3><code class="docutils literal notranslate"><span class="pre">verbose_name_plural</span></code><a class="headerlink" href="#verbose-name-plural" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.verbose_name_plural">
<code class="descclassname">Options.</code><code class="descname">verbose_name_plural</code><a class="headerlink" href="#django.db.models.Options.verbose_name_plural" title="Permalink to this definition">¶</a></dt>
<dd><p>The plural name for the object:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">verbose_name_plural</span> <span class="o">=</span> <span class="s2">&quot;stories&quot;</span>
</pre></div>
</div>
<p>If this isn’t given, Django will use <a class="reference internal" href="#django.db.models.Options.verbose_name" title="django.db.models.Options.verbose_name"><code class="xref py py-attr docutils literal notranslate"><span class="pre">verbose_name</span></code></a> + <code class="docutils literal notranslate"><span class="pre">&quot;s&quot;</span></code>.</p>
</dd></dl>

</div>
</div>
<div class="section" id="s-read-only-meta-attributes">
<span id="read-only-meta-attributes"></span><h2>Read-only <code class="docutils literal notranslate"><span class="pre">Meta</span></code> attributes<a class="headerlink" href="#read-only-meta-attributes" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-label">
<span id="label"></span><h3><code class="docutils literal notranslate"><span class="pre">label</span></code><a class="headerlink" href="#label" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.label">
<code class="descclassname">Options.</code><code class="descname">label</code><a class="headerlink" href="#django.db.models.Options.label" title="Permalink to this definition">¶</a></dt>
<dd><p>Representation of the object, returns <code class="docutils literal notranslate"><span class="pre">app_label.object_name</span></code>, e.g.
<code class="docutils literal notranslate"><span class="pre">'polls.Question'</span></code>.</p>
</dd></dl>

</div>
<div class="section" id="s-label-lower">
<span id="label-lower"></span><h3><code class="docutils literal notranslate"><span class="pre">label_lower</span></code><a class="headerlink" href="#label-lower" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Options.label_lower">
<code class="descclassname">Options.</code><code class="descname">label_lower</code><a class="headerlink" href="#django.db.models.Options.label_lower" title="Permalink to this definition">¶</a></dt>
<dd><p>Representation of the model, returns <code class="docutils literal notranslate"><span class="pre">app_label.model_name</span></code>, e.g.
<code class="docutils literal notranslate"><span class="pre">'polls.question'</span></code>.</p>
</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Model <code class="docutils literal notranslate"><span class="pre">Meta</span></code> options</a><ul>
<li><a class="reference internal" href="#available-meta-options">Available <code class="docutils literal notranslate"><span class="pre">Meta</span></code> options</a><ul>
<li><a class="reference internal" href="#abstract"><code class="docutils literal notranslate"><span class="pre">abstract</span></code></a></li>
<li><a class="reference internal" href="#app-label"><code class="docutils literal notranslate"><span class="pre">app_label</span></code></a></li>
<li><a class="reference internal" href="#base-manager-name"><code class="docutils literal notranslate"><span class="pre">base_manager_name</span></code></a></li>
<li><a class="reference internal" href="#db-table"><code class="docutils literal notranslate"><span class="pre">db_table</span></code></a><ul>
<li><a class="reference internal" href="#table-names">Table names</a></li>
</ul>
</li>
<li><a class="reference internal" href="#db-tablespace"><code class="docutils literal notranslate"><span class="pre">db_tablespace</span></code></a></li>
<li><a class="reference internal" href="#default-manager-name"><code class="docutils literal notranslate"><span class="pre">default_manager_name</span></code></a></li>
<li><a class="reference internal" href="#default-related-name"><code class="docutils literal notranslate"><span class="pre">default_related_name</span></code></a></li>
<li><a class="reference internal" href="#get-latest-by"><code class="docutils literal notranslate"><span class="pre">get_latest_by</span></code></a></li>
<li><a class="reference internal" href="#managed"><code class="docutils literal notranslate"><span class="pre">managed</span></code></a></li>
<li><a class="reference internal" href="#order-with-respect-to"><code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code></a></li>
<li><a class="reference internal" href="#ordering"><code class="docutils literal notranslate"><span class="pre">ordering</span></code></a></li>
<li><a class="reference internal" href="#permissions"><code class="docutils literal notranslate"><span class="pre">permissions</span></code></a></li>
<li><a class="reference internal" href="#default-permissions"><code class="docutils literal notranslate"><span class="pre">default_permissions</span></code></a></li>
<li><a class="reference internal" href="#proxy"><code class="docutils literal notranslate"><span class="pre">proxy</span></code></a></li>
<li><a class="reference internal" href="#required-db-features"><code class="docutils literal notranslate"><span class="pre">required_db_features</span></code></a></li>
<li><a class="reference internal" href="#required-db-vendor"><code class="docutils literal notranslate"><span class="pre">required_db_vendor</span></code></a></li>
<li><a class="reference internal" href="#select-on-save"><code class="docutils literal notranslate"><span class="pre">select_on_save</span></code></a></li>
<li><a class="reference internal" href="#indexes"><code class="docutils literal notranslate"><span class="pre">indexes</span></code></a></li>
<li><a class="reference internal" href="#unique-together"><code class="docutils literal notranslate"><span class="pre">unique_together</span></code></a></li>
<li><a class="reference internal" href="#index-together"><code class="docutils literal notranslate"><span class="pre">index_together</span></code></a></li>
<li><a class="reference internal" href="#verbose-name"><code class="docutils literal notranslate"><span class="pre">verbose_name</span></code></a></li>
<li><a class="reference internal" href="#verbose-name-plural"><code class="docutils literal notranslate"><span class="pre">verbose_name_plural</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#read-only-meta-attributes">Read-only <code class="docutils literal notranslate"><span class="pre">Meta</span></code> attributes</a><ul>
<li><a class="reference internal" href="#label"><code class="docutils literal notranslate"><span class="pre">label</span></code></a></li>
<li><a class="reference internal" href="#label-lower"><code class="docutils literal notranslate"><span class="pre">label_lower</span></code></a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="class.html"
                        title="previous chapter">Model class reference</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="instances.html"
                        title="next chapter">Model instance reference</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/ref/models/options.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <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>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Feb 11, 2019</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="class.html" title="Model class reference">previous</a>
     |
    <a href="../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="instances.html" title="Model instance reference">next</a> &raquo;</div>
    </div>
  </div>

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