Complete the code to filter books by title containing a search term.
books = Book.objects.filter(title__[1]=search_term)The contains lookup filters records where the field contains the given substring.
Complete the code to filter books published after a given year.
books = Book.objects.filter(publish_year__[1]=year)The gt lookup means 'greater than', so it filters books published after the given year.
Fix the error in filtering books with author name case-insensitive match.
books = Book.objects.filter(author__[1]=author_name)The iexact lookup matches the exact string ignoring case, which is needed here.
Fill both blanks to filter books with title containing a term and published before a year.
books = Book.objects.filter(title__[1]=term, publish_year__[2]=year)
Use icontains for case-insensitive title search and lt for years less than the given year.
Fill all three blanks to filter books with author name case-insensitive, title containing term, and published after year.
books = Book.objects.filter(author__[1]=author_name, title__[2]=term, publish_year__[3]=year)
Use iexact for author name case-insensitive exact match, icontains for title substring ignoring case, and gt for published after the year.