Ticket #12663: document-meta.diff

File document-meta.diff, 2.6 KB (added by Adam Vandenberg, 14 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  
    33======================
    44
    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.
    87
    98.. _table-names:
    109
    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``.
    2322
    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.
    2625
    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  
    3332
    3433.. currentmodule:: django.db.models
    3534
     35.. class:: Options
     36
     37.. note::
     38
     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.
     42
    3643.. attribute:: Options.abstract
    3744
    3845    If ``True``, this model will be an
    Available ``Meta`` options  
    209216
    210217    If this isn't given, Django will use
    211218    :attr:`~Options.verbose_name` + ``"s"``.
     219
     220
     221Meta information at runtime
     222===========================
     223
     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.
     227
     228.. attribute:: Options.auto_field
     229
     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.
     233
     234.. attribute:: Options.has_auto_field
     235
     236    ``True`` if this model has an :class:`~django.db.models.AutoField`. If
     237    ``True``, :attr:`Options.auto_field` returns this field.
     238
     239.. attribute:: Options.pk
     240
     241    Returns the :attr:`~Field.primary_key` field for this Model, either one
     242    explicitly defined or the generated :class:`~django.db.models.AutoField`.
     243
     244.. method:: Options.get_field(name, many_to_many=True)
     245
     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