Wagtail Unboxed episode 11 3:50
Search
The search app we unboxed in episode 2 finally does something. It works out of the box, and this episode finds four ways it doesn't work well, every one measured.
What this episode covers
Only titles are searched. Adding fields changes nothing until you rebuild the index. Text that comes from snippets is visible on the page but can't be found. And the view Wagtail generates shows the titles of password-protected pages to anyone.
What you'll learn
- What Wagtail indexes by default: the title, and nothing else you wrote
search_fields:SearchFieldandFilterField- Why adding
search_fieldschanges nothing, andupdate_index get_searchable_content: indexing text that lives in snippets- The private-page leak in the generated view, and .
public() - .
specific()so results can show their intro - A search results template with a count, page types and pagination
- Putting search in the menu
Chapters
- 0:00 The app we unboxed in episode 2
- 0:21 Only titles are searched
- 0:33 search_fields
- 0:50 Still nothing
- 0:56 update_index
- 1:16 Visible, but not searchable
- 1:39 get_searchable_content
- 2:07 Password-protect a page, then search
- 2:20 The generated view leaks private pages
- 2:43 The view, rewritten
- 2:57 The results template
- 3:11 Search in the menu
- 3:20 A name from a snippet
- 3:27 Commit and tag
- 3:30 Next: Act 3
Versions on screen
Wagtail 7.4.3 · Django 6.1.1 · Python 3.12. Recorded on Windows; macOS and Linux commands are in the repository for every episode.