Ticket #12663: document-meta.diff
File document-meta.diff, 2.6 KB (added by , 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 3 3 ====================== 4 4 5 5 This 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. 8 7 9 8 .. _table-names: 10 9 … … For example, if you have an app ``bookstore`` (as created by 21 20 ``manage.py startapp bookstore``), a model defined as ``class Book`` will have 22 21 a database table named ``bookstore_book``. 23 22 24 To override the database table name, use the ``db_table`` parameter in25 ``class Meta``.23 To override the database table name, use the 24 :attr:`~django.db.models.Options.db_table` attribute. 26 25 27 26 If your database table name is an SQL reserved word, or contains characters that 28 27 aren't allowed in Python variable names -- notably, the hyphen -- that's OK. … … Available ``Meta`` options 33 32 34 33 .. currentmodule:: django.db.models 35 34 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 36 43 .. attribute:: Options.abstract 37 44 38 45 If ``True``, this model will be an … … Available ``Meta`` options 209 216 210 217 If this isn't given, Django will use 211 218 :attr:`~Options.verbose_name` + ``"s"``. 219 220 221 Meta information at runtime 222 =========================== 223 224 Model instances have a ``_meta`` attribute, which is an instance of 225 :class:`django.db.models.Options`. Any of the properties listed above are 226 available 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`.