| 108 | |
| 109 | # If you delete an object with an explicit Generic relation, the related |
| 110 | # objects are deleted when the source object is deleted. |
| 111 | >>> [(p.tag, p.content_type, p.object_id) for p in TaggedItem.objects.all()] |
| 112 | [('clearish', <ContentType: mineral>, 1), ('fatty', <ContentType: vegetable>, 2), ('hairy', <ContentType: animal>, 1), ('salty', <ContentType: vegetable>, 2), ('shiny', <ContentType: animal>, 2), ('yellow', <ContentType: animal>, 1)] |
| 113 | |
| 114 | >>> lion.delete() |
| 115 | >>> [(p.tag, p.content_type, p.object_id) for p in TaggedItem.objects.all()] |
| 116 | [('clearish', <ContentType: mineral>, 1), ('fatty', <ContentType: vegetable>, 2), ('salty', <ContentType: vegetable>, 2), ('shiny', <ContentType: animal>, 2)] |
| 117 | |
| 118 | # If Generic Relation is not explicitly defined, any tags remain after deletion. |
| 119 | >>> quartz.delete() |
| 120 | [('clearish', <ContentType: mineral>, 1), ('fatty', <ContentType: vegetable>, 2), ('salty', <ContentType: vegetable>, 2), ('shiny', <ContentType: animal>, 2)] |
| 121 | |