Challenge - 5 Problems
Search and Filter Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate1:30remaining
What is the output of this Django queryset filter?
Given the model
Book with fields title and author, what does this queryset return?Book.objects.filter(title__icontains='django')Attempts:
2 left
💡 Hint
Look at the double underscore and the 'icontains' part in the filter.
✗ Incorrect
The filter
title__icontains='django' returns all books where the title contains the substring 'django' regardless of case.📝 Syntax
intermediate1:30remaining
Which option correctly filters books published after 2020?
Assuming
Book has a published_year integer field, which queryset filters books published after 2020?Attempts:
2 left
💡 Hint
Look for the correct Django field lookup for greater than.
✗ Incorrect
The correct lookup for greater than is
__gt. Option A uses it correctly.🔧 Debug
advanced1:30remaining
Why does this filter raise an error?
What error does this code raise?
Book.objects.filter(title__icontains)Attempts:
2 left
💡 Hint
Check the filter method call and its arguments.
✗ Incorrect
The filter method requires keyword arguments with values. Omitting the value causes a TypeError about missing arguments.
❓ state_output
advanced1:30remaining
How many items are in the queryset after this filter?
If the database has 5 books with titles: ['Django Basics', 'Advanced Django', 'Flask Guide', 'Django Tips', 'Python Tricks'], what is the count of
Book.objects.filter(title__icontains='django')?Attempts:
2 left
💡 Hint
Count titles containing 'django' ignoring case.
✗ Incorrect
Titles containing 'django' are 'Django Basics', 'Advanced Django', and 'Django Tips' — total 3.
🧠 Conceptual
expert2:00remaining
Which option best describes the difference between filter() and exclude()?
In Django querysets, what is the main difference between
filter() and exclude() methods?Attempts:
2 left
💡 Hint
Think about what each method keeps or removes from the results.
✗ Incorrect
filter() keeps items matching the condition, while exclude() removes those matching the condition.