From 78ca7a6c073e07f311e37b45d8dfe7fce7465e06 Mon Sep 17 00:00:00 2001 From: James Bennett Date: Sun, 31 Aug 2008 10:13:32 +0000 Subject: 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 --- docs/ref/models/fields.txt | 32 +++++++++++++++++++++++++++----- docs/ref/models/options.txt | 10 +++++++++- 2 files changed, 36 insertions(+), 6 deletions(-) (limited to 'docs/ref') diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 909bfeff1f..bf5d7b30cd 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -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 ` 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 + `; and when you do so + :ref:`some special syntax ` 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 `, 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. diff --git a/docs/ref/models/options.txt b/docs/ref/models/options.txt index 34ec7a19ed..745e8ceb4f 100644 --- a/docs/ref/models/options.txt +++ b/docs/ref/models/options.txt @@ -4,13 +4,21 @@ Model ``Meta`` options ====================== -This document explains all the possible :ref:`metadata options ` that you can give your model in its internal ``class Meta``. +This document explains all the possible :ref:`metadata 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 `. + ``db_table`` ------------ -- cgit v1.3