def delete(self, *args, **kwargs):
from bakery import tasks<EOL>from django.contrib.contenttypes.models import ContentType<EOL>unpublish = kwargs.pop('<STR_LIT>', True)<EOL>super(AutoPublishingBuildableModel, self).delete(*args, **kwargs)<EOL>if unpublish:<EOL><INDENT>ct = ContentType.objects.get_for_model(self.__class__)<EOL>tasks.unpublish_object.delay(ct.pk, self.pk)<EOL><DEDENT>
Triggers a task that will unpublish the object after it is deleted.

Save with keyword argument obj.delete(unpublish=False) to skip it.