create a dictionary of with key as the attribute and value as model object

Say i have this table:

class Blog(models.Model)
  title = models.CharField()
  body = models.CharField()
  author = models.ForeignKey(Author)

I need to create 3 rows with the title (title_1, title_2, title_3). I need to fetch all the blog objects and create a dictionary with key as the title and value as blog object.

blog_dict = {'title_1': <blog_object_1>, 'title_2': <blog_object_2>, 'title_2': <blog_object_3>}

I have 1 million records to work. Is there any efficient way to do it?

Answer

this might do this task

blog_dict = {}
blogs = Blog.objects.all()
for blog in blogs:
    blog_dict[blog.title] = blog

as @ZXYNINE mentioned in the comment section below, it could be done with a single line instead of full form of for loop like so:

blog_dict  = { blog.title:blog for blog in blogs}

I find the first method is better for beginners, but also it worth to mention the other method as well.