0
0
Djangoframework~10 mins

Search and filter options in Django - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to filter books by title containing a search term.

Django
books = Book.objects.filter(title__[1]=search_term)
Drag options to blanks, or click blank then click option'
Acontains
Bexact
Cstartswith
Dendswith
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'exact' instead of 'contains' causes no partial matches.
2fill in blank
medium

Complete the code to filter books published after a given year.

Django
books = Book.objects.filter(publish_year__[1]=year)
Drag options to blanks, or click blank then click option'
Alt
Bgt
Clte
Dgte
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gte' includes the year itself, which may not be desired.
3fill in blank
hard

Fix the error in filtering books with author name case-insensitive match.

Django
books = Book.objects.filter(author__[1]=author_name)
Drag options to blanks, or click blank then click option'
Aiexact
Bcontains
Cexact
Dicontains
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'exact' causes case-sensitive match, missing some results.
4fill in blank
hard

Fill both blanks to filter books with title containing a term and published before a year.

Django
books = Book.objects.filter(title__[1]=term, publish_year__[2]=year)
Drag options to blanks, or click blank then click option'
Aicontains
Bcontains
Clt
Dgt
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'contains' misses case-insensitive matches.
Using 'gt' filters wrong years.
5fill in blank
hard

Fill all three blanks to filter books with author name case-insensitive, title containing term, and published after year.

Django
books = Book.objects.filter(author__[1]=author_name, title__[2]=term, publish_year__[3]=year)
Drag options to blanks, or click blank then click option'
Aiexact
Bicontains
Cgt
Dcontains
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'exact' causes case-sensitive author match.
Using 'contains' misses case-insensitive title matches.
Using 'gte' includes the year itself.