code: def save(self, *args, **kwargs):
          
          from bakery import tasks
          from django.contrib.contenttypes.models import ContentType
          # if obj.save(publish=False) has been passed, we skip everything.
          if not kwargs.pop('publish', True):
              super(AutoPublishingBuildableModel, self).save(*args, **kwargs)
          # Otherwise, for the standard obj.save(), here we go...
          else:
              # First figure out if the record is an addition, or an edit of
              # a preexisting record.
              try:
                  preexisting = self.__class__.objects.get(pk=self.pk)
              except self.__class__.DoesNotExist:
                  preexisting = None
              # If this is an addition...
              if not preexisting:
                  # We will publish if that's the boolean
                  if self.get_publication_status():
                      action = 'publish'
                  # Otherwise we will do nothing do nothing
                  else:
                      action = None
              # If this is an edit...
              else:
                  # If it's being unpublished...
                  if not self.get_publication_status() and \
                          preexisting.get_publication_status():
                      action = 'unpublish'
                  # If it's being published...
                  elif self.get_publication_status():
                      action = 'publish'
                  # If it's remaining unpublished...
                  else:
                      action = None
              # Now, no matter what, save it normally inside of a dedicated
              # database transaction so that we are sure that the save will
              # be complete before we trigger any task
              with transaction.atomic():
                  super(AutoPublishingBuildableModel, self).save(*args, **kwargs)
              # Finally, depending on the action, fire off a task
              ct = ContentType.objects.get_for_model(self.__class__)
              if action == 'publish':
                  tasks.publish_object.delay(ct.pk, self.pk)
              elif action == 'unpublish':
                  tasks.unpublish_object.delay(ct.pk, self.pk)
docs: A custom save that publishes or unpublishes the object where
          appropriate.
  
          Save with keyword argument obj.save(publish=False) to skip the process.