If you came here from Google looking for model to dict, skip my question, and just jump down to the first answer. My question will only confuse you.
Is ther
You want the in_bulk queryset method which, according to the docs:
Takes a list of field values (
id_list) and thefield_namefor those values, and returns a dictionary mapping each value to an instance of the object with the given field value. Ifid_listisn’t provided, all objects in the queryset are returned.field_namemust be a unique field, and it defaults to the primary key.
It takes a list of IDs, so you'll need to get that first via the values_list method:
ids = MyModel.objects.values_list('id', flat=True)
ids_to_model_instances = MyModel.objects.in_bulk(ids)
# {1: , 2: , 3: }