instance
is the Contact
object here. So, instance.id
would give you the id of the contact object
from django.db.models.signals import pre_delete
from django.dispatch import receiver
@receiver(pre_delete, sender=Contact, dispatch_uid='<whatever>')
def contact_delete(sender, instance, using, **kwargs):
from unsubscribe.models import Unsubscribe
unsubscribe_list = Unsubscribe.objects.filter(object_id=instance.id, content_type__model='contact')
for item in unsubscribe_list: #This should be a single element in the queryset.
item.delete()