(model, ids, fields=None)
Fetches a dict of model details for model instances with the given
    ids, keyed by their id.

    If a fields list is given, a dict of details will be retrieved for
    each model, otherwise complete model instances will be retrieved.

    Any fields list given shouldn't contain the primary key attribute for
    the model, as this can be determined from its Options.
Fetches a dict of model details for model instances with the given
    ids, keyed by their id.
Fetches a dict of model details for model instances with the given ids keyed by their id .
def fetch_model_dict(model, ids, fields=None):
    """
    Fetches a dict of model details for model instances with the given
    ids, keyed by their id.

    If a fields list is given, a dict of details will be retrieved for
    each model, otherwise complete model instances will be retrieved.

    Any fields list given shouldn't contain the primary key attribute for
    the model, as this can be determined from its Options.
    """
    if fields is None:
        return model._default_manager.in_bulk(ids)
    else:
        id_attr = model._meta.pk.attname
        return dict((obj[id_attr], obj) for obj
            in model._default_manager.filter(id__in=ids).values(
                *itertools.chain((id_attr,), fields)))
def fetch_model_dict ( model , ids , fields = None ) : if fields is None : return model . _default_manager . in_bulk ( ids ) else : id_attr = model . _meta . pk . attname return dict ( ( obj [ id_attr ] , obj ) for obj in model . _default_manager . filter ( id__in = ids ) . values ( * itertools . chain ( ( id_attr , ) , fields ) ) )