def process_label_request(request, label, instance):
    http_status = status.HTTP_200_OK

    if request.method == 'POST':
        http_status = _labels_post(request, instance)

    if request.method == 'GET' and label:
        data = [tag['name']
                for tag in instance.tags.filter(name=label).values('name')]
    elif request.method == 'DELETE' and label:
        http_status, data = _labels_delete(label, instance)
    else:
        data = list(instance.tags.names())

    return Response(data, status=http_status)
Process request to labels endpoint.
dataset/ETHPy150Open kobotoolbox/kobocat/onadata/libs/mixins/labels_mixin.py/process_label_request