Complete the code to import the Django signal for actions before deleting an object.
from django.db.models.signals import [1]
The pre_delete signal is sent just before a model's delete() method is called.
Complete the code to connect a function to the post_delete signal for a model named Book.
post_delete.connect([1], sender=Book)The function connected to post_delete should handle actions after deletion, so a name like handle_post_delete fits best.
Fix the error in the signal handler definition to accept the correct parameters for pre_delete.
def my_handler([1], instance, **kwargs): print(f"Deleting {instance}")
Signal handlers receive sender as the first argument, not self or others.
Fill both blanks to create a pre_delete signal handler that prints the instance being deleted and connect it to the Author model.
def [1](sender, instance, **kwargs): print(f"About to delete [2]") pre_delete.connect(delete_notice, sender=Author)
The handler function is named delete_notice and it prints the instance being deleted.
Fill all three blanks to create a post_delete handler that logs the deleted object's ID and connect it to the Publisher model.
def [1](sender, instance, [2]): print(f"Deleted object ID: {instance.[3]") post_delete.connect(log_deletion, sender=Publisher)
The handler is named log_deletion, accepts **kwargs, and prints the id of the deleted instance.