code: def unpublish_object(content_type_pk, obj_pk):
      
      ct = ContentType.objects.get_for_id(content_type_pk)
      obj = ct.get_object_for_this_type(pk=obj_pk)
      try:
          # Unbuild the object
          logger.info("unpublish_object task has received %s" % obj)
          obj.unbuild()
          # Run the `publish` management command unless the
          # ALLOW_BAKERY_AUTO_PUBLISHING variable is explictly set to False.
          if not getattr(settings, 'ALLOW_BAKERY_AUTO_PUBLISHING', True):
              logger.info("Not running publish command because \
  ALLOW_BAKERY_AUTO_PUBLISHING is False")
          else:
              management.call_command("publish")
      except Exception:
          # Log the error if this crashes
          logger.error("Task Error: unpublish_object", exc_info=True)
docs: Unbuild all views related to a object and then sync to S3.
  
      Accepts primary keys to retrieve a model object that
      inherits bakery's BuildableModel class.