def get_referenced_records(data, ModelToUpdate, pk):
    """
    Return all elements of type 'ModelToUpdate' referenced in the 'data' by its primary key ('pk' parameter)
    """
    pks = [row[pk] for row in data]
    query_dict = {"%s__in" % pk: pks}
    return ModelToUpdate.objects.filter(**query_dict)