Ticket #32045: 32045.diff

File 32045.diff, 1.3 KB (added by Craig Smith, 4 years ago)

Patch to update documentation about remove and clear methods on GenericRelation manager

  • docs/ref/contrib/contenttypes.txt

    diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt
    index 28a2e40819..cc8671b1b9 100644
    a b behavior; if desired, you can avoid the cascade-deletion by not using  
    443443behavior can be provided via the :data:`~django.db.models.signals.pre_delete`
    444444signal.
    445445
     446Methods on ``GenericRelation`` managers
     447---------------------------------------
     448
     449    .. method:: remove(*objs, bulk=True)
     450
     451        Removes the specified model objects from the related object set and
     452        deletes them from the database.
     453
     454    .. code-block:: python
     455
     456        >>> b.tags.remove(t) # Deletes TaggedItem t from database.
     457
     458    .. method:: clear()
     459
     460        Removes all items from the related object set and deletes them from the
     461        database.
     462
     463    .. code-block:: python
     464
     465        >>> b.tags.clear() # Deletes all related TaggedItems from database.
     466
     467In both the above examples this behaviour differs from that of
     468:class:`django.db.models.fields.related.RelatedManager` which has
     469methods named ``remove`` and ``clear`` which disassociate the
     470related objects without deleting them from the database.
     471
    446472Generic relations and aggregation
    447473---------------------------------
    448474
Back to Top