summaryrefslogtreecommitdiff
path: root/docs/topics
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-10-02 12:12:53 -0400
committerTim Graham <timograham@gmail.com>2013-10-02 12:12:53 -0400
commit75bb6ba96660e2a06e18d99120c05db2bb9fa9cc (patch)
treedf52d4b0266d6c2803f7b90b6e07f43b678ec848 /docs/topics
parente1b77238171cc96f4451a06fb4682e2378896238 (diff)
Fixed #10913 -- Documented how related_name affects QuerySet filtering
Thanks neithere for the suggestion.
Diffstat (limited to 'docs/topics')
-rw-r--r--docs/topics/db/queries.txt14
1 files changed, 8 insertions, 6 deletions
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt
index 696bddac95..19c1af7c0f 100644
--- a/docs/topics/db/queries.txt
+++ b/docs/topics/db/queries.txt
@@ -1124,8 +1124,9 @@ Example::
>>> b.entry_set.filter(headline__contains='Lennon')
>>> b.entry_set.count()
-You can override the ``FOO_set`` name by setting the ``related_name``
-parameter in the ``ForeignKey()`` definition. For example, if the ``Entry``
+You can override the ``FOO_set`` name by setting the
+:attr:`~django.db.models.ForeignKey.related_name` parameter in the
+:class:`~django.db.models.ForeignKey` definition. For example, if the ``Entry``
model was altered to ``blog = ForeignKey(Blog, related_name='entries')``, the
above example code would look like this::
@@ -1224,10 +1225,11 @@ An example makes this easier to understand::
a.entry_set.all() # Returns all Entry objects for this Author.
Like :class:`~django.db.models.ForeignKey`,
-:class:`~django.db.models.ManyToManyField` can specify ``related_name``. In the
-above example, if the :class:`~django.db.models.ManyToManyField` in ``Entry``
-had specified ``related_name='entries'``, then each ``Author`` instance would
-have an ``entries`` attribute instead of ``entry_set``.
+:class:`~django.db.models.ManyToManyField` can specify
+:attr:`~django.db.models.ManyToManyField.related_name`. In the above example,
+if the :class:`~django.db.models.ManyToManyField` in ``Entry`` had specified
+``related_name='entries'``, then each ``Author`` instance would have an
+``entries`` attribute instead of ``entry_set``.
One-to-one relationships
------------------------