Ticket #11047: 11047.diff

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

further clarification based on existing patch

  • docs/ref/contrib/contenttypes.txt

     
    324324    ...                           object_id=b.id)
    325325    [<TaggedItem: django>, <TaggedItem: python>]
    326326
    327 Note that if the model with a :class:`~django.contrib.contenttypes.generic.GenericForeignKey`
    328 that you're referring to uses a non-default value for ``ct_field`` or ``fk_field``
    329 (e.g. the :mod:`django.contrib.comments` app uses ``ct_field="object_pk"``),
    330 you'll need to pass ``content_type_field`` and ``object_id_field`` to
    331 :class:`~django.contrib.contenttypes.generic.GenericRelation`.::
     327Note that if the model in a
     328:class:`~django.contrib.contenttypes.generic.GenericRelation` uses a
     329non-default value for ``ct_field`` or ``fk_field`` in its
     330:class:`~django.contrib.contenttypes.generic.GenericForeignKey` (e.g. the
     331:mod:`django.contrib.comments` app uses ``ct_field="object_pk"``),
     332you'll need to set ``content_type_field`` and/or ``object_id_field`` in
     333the :class:`~django.contrib.contenttypes.generic.GenericRelation` to
     334match the ``ct_field`` and ``fk_field``, respectively, in the
     335:class:`~django.contrib.contenttypes.generic.GenericForeignKey`::
    332336
    333         comments = generic.GenericRelation(Comment, content_type_field="content_type", object_id_field="object_pk")
     337        comments = generic.GenericRelation(Comment, object_id_field="object_pk")
    334338
    335 Note that if you delete an object that has a
     339Note also, that if you delete an object that has a
    336340:class:`~django.contrib.contenttypes.generic.GenericRelation`, any objects
    337341which have a :class:`~django.contrib.contenttypes.generic.GenericForeignKey`
    338342pointing at it will be deleted as well. In the example above, this means that
Back to Top