Ticket #12663: document-meta.diff

File document-meta.diff, 2.6 KB (added by adamv, 5 years ago)
  • docs/ref/models/options.txt

    diff --git a/docs/ref/models/options.txt b/docs/ref/models/options.txt
    index cfae675..dc2870e 100644
    a b Model ``Meta`` options 
    55This document explains all the possible :ref:`metadata options
    6 <meta-options>` that you can give your model in its internal ``class
    7 Meta``.
     6<meta-options>` that you can give your model in its internal ``Meta`` class.
    98.. _table-names:
    For example, if you have an app ``bookstore`` (as created by 
    2120``manage.py startapp bookstore``), a model defined as ``class Book`` will have
    2221a database table named ``bookstore_book``.
    24 To override the database table name, use the ``db_table`` parameter in
    25 ``class Meta``.
     23To override the database table name, use the
     24:attr:`~django.db.models.Options.db_table` attribute.
    2726If your database table name is an SQL reserved word, or contains characters that
    2827aren't allowed in Python variable names -- notably, the hyphen -- that's OK.
    Available ``Meta`` options 
    3433.. currentmodule:: django.db.models
     35.. class:: Options
     37.. note::
     39    At runtime, the properties assigned to the ``Meta`` class are transfered
     40    to an instance of :class:`django.db.models.Options`. See `Meta information at
     41    runtime`_ below for more information.
    3643.. attribute:: Options.abstract
    3845    If ``True``, this model will be an
    Available ``Meta`` options 
    210217    If this isn't given, Django will use
    211218    :attr:`~Options.verbose_name` + ``"s"``.
     221Meta information at runtime
     224Model instances have a ``_meta`` attribute, which is an instance of
     225:class:`django.db.models.Options`. Any of the properties listed above are
     226available on ``_meta`` as well as those listed below.
     228.. attribute:: Options.auto_field
     230    If the model has an :class:`~django.db.models.AutoField`, this property
     231    will return that field. Otherwise, this property will be undefined.
     232    Check :attr:`Options.has_auto_field` before trying to access.
     234.. attribute:: Options.has_auto_field
     236    ``True`` if this model has an :class:`~django.db.models.AutoField`. If
     237    ``True``, :attr:`Options.auto_field` returns this field.
     239.. attribute:: Options.pk
     241    Returns the :attr:`~Field.primary_key` field for this Model, either one
     242    explicitly defined or the generated :class:`~django.db.models.AutoField`.
     244.. method:: Options.get_field(name, many_to_many=True)
     246    Returns the field with the given name. If the field does not exist for
     247    this model, raises :exc:`~django.db.models.fields.FieldDoesNotExist`.
Back to Top