Complete the code to define a Django model representing a simple Book with a title.
from django.db import models class Book(models.Model): title = models.[1](max_length=100)
The CharField is used to store text data like a book title in Django models.
Complete the code to query all Book objects from the database using Django ORM.
books = Book.[1].all()The objects manager is used to access database queries in Django ORM.
Fix the error in the code to save a new Book instance to the database.
book = Book(title='Django Basics') book.[1]()
The save() method saves the model instance to the database.
Fill both blanks to filter Books with titles containing 'Django' and order them by title.
books = Book.objects.[1](title__icontains='Django').[2]('title')
filter() narrows down records matching the condition, and order_by() sorts them by the given field.
Fill all three blanks to create a dictionary mapping book titles to their IDs for books published after 2020.
books_dict = {book.[1]: book.[2] for book in Book.objects.[3](published_year__gt=2020)}This dictionary comprehension uses filter() to get books published after 2020, then maps each book's title to its id.