Code

Ticket #11047: 11047.diff

File 11047.diff, 1.8 KB (added by timo, 4 years ago)

further clarification based on existing patch

Line 
1Index: docs/ref/contrib/contenttypes.txt
2===================================================================
3--- docs/ref/contrib/contenttypes.txt   (revision 11797)
4+++ docs/ref/contrib/contenttypes.txt   (working copy)
5@@ -324,15 +324,19 @@
6     ...                           object_id=b.id)
7     [<TaggedItem: django>, <TaggedItem: python>]
8 
9-Note that if the model with a :class:`~django.contrib.contenttypes.generic.GenericForeignKey`
10-that you're referring to uses a non-default value for ``ct_field`` or ``fk_field``
11-(e.g. the :mod:`django.contrib.comments` app uses ``ct_field="object_pk"``),
12-you'll need to pass ``content_type_field`` and ``object_id_field`` to
13-:class:`~django.contrib.contenttypes.generic.GenericRelation`.::
14+Note that if the model in a
15+:class:`~django.contrib.contenttypes.generic.GenericRelation` uses a
16+non-default value for ``ct_field`` or ``fk_field`` in its
17+:class:`~django.contrib.contenttypes.generic.GenericForeignKey` (e.g. the
18+:mod:`django.contrib.comments` app uses ``ct_field="object_pk"``),
19+you'll need to set ``content_type_field`` and/or ``object_id_field`` in
20+the :class:`~django.contrib.contenttypes.generic.GenericRelation` to
21+match the ``ct_field`` and ``fk_field``, respectively, in the
22+:class:`~django.contrib.contenttypes.generic.GenericForeignKey`::
23 
24-       comments = generic.GenericRelation(Comment, content_type_field="content_type", object_id_field="object_pk")
25+       comments = generic.GenericRelation(Comment, object_id_field="object_pk")
26 
27-Note that if you delete an object that has a
28+Note also, that if you delete an object that has a
29 :class:`~django.contrib.contenttypes.generic.GenericRelation`, any objects
30 which have a :class:`~django.contrib.contenttypes.generic.GenericForeignKey`
31 pointing at it will be deleted as well. In the example above, this means that