tcms.utils.dict_utils module

tcms.utils.dict_utils.create_dict_from_query(query, key_field, skip_others=False)[source]

Group values based on a particular field.

@param query: Django values() query, ordered by key_field
or any other iterator that returns dicts

@param key_field: field name by which to grup @param skip_others: if given the result will contain only the

first record matching key_field. This is useful when we want to filter only the latest varsions of some records.
@return: dict where keys are key_field values and
values are a list of the query records.