Kaydet (Commit) 78ca7a6c authored tarafından James Bennett's avatar James Bennett

Fixed #8533: restored model inheritance docs, and updated one-to-one docs to match

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8757 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 27f9b96f
......@@ -811,7 +811,10 @@ define the details of how the relation works.
The name to use for the relation from the related object back to this one.
See the :ref:`related objects documentation <backwards-related-objects>` for
a full explanation and example.
a full explanation and example. Note that you must set this value
when defining relations on :ref:`abstract models
<abstract-base-classes>`; and when you do so
:ref:`some special syntax <abstract-related-name>` is available.
.. attribute:: ForeignKey.to_field
......@@ -883,8 +886,27 @@ that control how the relationship functions.
``OneToOneField``
-----------------
.. class:: OneToOneField(othermodel, [**options])
.. class:: OneToOneField(othermodel, [parent_link=False, **options])
The semantics of one-to-one relationships will be changing soon, so we don't
recommend you use them. If that doesn't scare you away, however,
:class:`OneToOneField` takes the same options that :class:`ForeignKey` does.
A one-to-one relationship. Conceptually, this is similar to a
:class:`ForeignKey` with :attr:`unique=True <Field.unique>`, but the
"reverse" side of the relation will directly return a single object.
This is most useful as the primary key of a model which "extends"
another model in some way; :ref:`multi-table-inheritance` is
implemented by adding an implicit one-to-one relation from the child
model to the parent model, for example.
One positional argument is required: the class to which the model will
be related.
Additionally, ``OneToOneField`` accepts all of the extra arguments
accepted by :class:`ForeignKey`, plus one extra argument:
.. attribute: OneToOneField.parent_link
When ``True`` and used in a model which inherits from another
(concrete) model, indicates that this field should be used as the
link back to the parent class, rather than the extra
``OneToOneField`` which would normally be implicitly created by
subclassing.
......@@ -4,13 +4,21 @@
Model ``Meta`` options
======================
This document explains all the possible :ref:`metadata options <meta-options>` that you can give your model in its internal ``class Meta``.
This document explains all the possible :ref:`metadata options <meta-options>` that you can give your model in its internal
``class Meta``.
Available ``Meta`` options
==========================
.. currentmodule:: django.db.models
``abstract``
------------
.. attribute:: Options.abstract
If ``True``, this model will be an :ref:`abstract base class <abstract-base-classes>`.
``db_table``
------------
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment