1π
β
In your delete_stream_item()
function, instance
is the object that has just been deleted, in your case either a Fe
or Event
instance. What you want is to retrieve all related StreamItem
instances (using the instance
ctype and pk) and delete them.
Warning: untested code:
def delete_stream_item(sender, instance, signal, *args, **kwargs):
ctype = ContentType.objects.get_for_model(instance)
StreamItem.objects.filter(content_type=ctype, object_id=instance.id).delete()
Source:stackexchange.com