def load_instances(model, primary_keys):
    """Load model instances preserving order of keys in the list."""
    instance_by_pk = model.objects.in_bulk(primary_keys)
    return [instance_by_pk[pk] for pk in primary_keys]