def METHOD_NAME(request, queryset, view, keyword):
    xform_id = request.query_params.get('xform')
    if not xform_id:
        lookup_field = view.lookup_field
        lookup = view.kwargs.get(lookup_field)
        if not lookup:
            return
        try:
            xform_id = queryset.values_list(
                '{keyword}_id'.format(keyword=keyword), flat=True
            ).get(pk=lookup)
        except ObjectDoesNotExist:
            raise Http404
    try:
        int(xform_id)
    except ValueError:
        raise ParseError(
            'Invalid value for formid {form_id}.'.format(form_id=xform_id)
        )
    return get_object_or_404(XForm, pk=xform_id)