@shared_task()
def unpublish_object(content_type_pk, obj_pk):
    """
    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.
    """
    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(obj % "unpublish_object task has received %s")
        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)
dataset/ETHPy150Open datadesk/django-bakery/bakery/tasks.py/unpublish_object/swapped operands of `%`