def METHOD_NAME(queryset):
    """Slice a queryset into batches.
    Input queryset should be sorted be pk.
    """
    start_pk = 0
    while True:
        qs = queryset.filter(pk__gt=start_pk)[:BATCH_SIZE]
        pks = list(qs.values_list("pk", flat=True))
        if not pks:
            break
        yield pks
        start_pk = pks[-1]