def METHOD_NAME(qs, value, gift_card_type):
    gift_card_events = GiftCardEvent.objects.filter(type=gift_card_type).values(
        "order_id"
    )
    lookup = Exists(gift_card_events.filter(order_id=OuterRef("id")))
    return qs.filter(lookup) if value is True else qs.exclude(lookup)