Fixed #14840 -- Added crossrefs to related objects reference docs. Thanks to adamv for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14842 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Gabriel Hurley 2010-12-06 11:49:31 +00:00
parent 0f5a7e0775
commit b407de3bc5
1 changed files with 10 additions and 8 deletions

View File

@ -9,7 +9,8 @@ Related objects reference
A "related manager" is a manager used in a one-to-many or many-to-many A "related manager" is a manager used in a one-to-many or many-to-many
related context. This happens in two cases: related context. This happens in two cases:
* The "other side" of a ``ForeignKey`` relation. That is:: * The "other side" of a :class:`~django.db.models.ForeignKey` relation.
That is::
class Reporter(models.Model): class Reporter(models.Model):
... ...
@ -20,7 +21,7 @@ Related objects reference
In the above example, the methods below will be available on In the above example, the methods below will be available on
the manager ``reporter.article_set``. the manager ``reporter.article_set``.
* Both sides of a ``ManyToManyField`` relation:: * Both sides of a :class:`~django.db.models.ManyToManyField` relation::
class Topping(models.Model): class Topping(models.Model):
... ...
@ -82,11 +83,12 @@ Related objects reference
>>> b.entry_set.remove(e) # Disassociates Entry e from Blog b. >>> b.entry_set.remove(e) # Disassociates Entry e from Blog b.
In order to prevent database inconsistency, this method only exists on In order to prevent database inconsistency, this method only exists on
``ForeignKey`` objects where ``null=True``. If the related field can't :class:`~django.db.models.ForeignKey` objects where ``null=True``. If
be set to ``None`` (``NULL``), then an object can't be removed from a the related field can't be set to ``None`` (``NULL``), then an object
relation without being added to another. In the above example, removing can't be removed from a relation without being added to another. In the
``e`` from ``b.entry_set()`` is equivalent to doing ``e.blog = None``, above example, removing ``e`` from ``b.entry_set()`` is equivalent to
and because the ``blog`` ``ForeignKey`` doesn't have ``null=True``, this doing ``e.blog = None``, and because the ``blog``
:class:`~django.db.models.ForeignKey` doesn't have ``null=True``, this
is invalid. is invalid.
.. method:: clear() .. method:: clear()
@ -100,4 +102,4 @@ Related objects reference
them. them.
Just like ``remove()``, ``clear()`` is only available on Just like ``remove()``, ``clear()`` is only available on
``ForeignKey``\s where ``null=True``. :class:`~django.db.models.ForeignKey`\s where ``null=True``.