1
我想刪除所有屬於的通用外鍵關係聯繫人刪除所述聯繫人時。pre_delete信號錯誤
這是我到目前爲止已經試過:
@receiver(pre_delete, sender=Contact):
def contact_delete(sender, instance, **kwargs):
from unsubscribe.models import Unsubscribe
unsubscribe_list = Unsubscribe.objects.filter(object_id=instance)
for item in unsubscribe_list:
item.delete()
我的問題是,如何獲取該實例的OBJECT_ID。我只想刪除正在刪除的對象的相關項目?
你試過'instance.pk'嗎? –