Ashish Pitrodafield notes
All episodes

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: SearchField and FilterField
  • Why adding search_fields changes nothing, and update_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

  1. 0:00 The app we unboxed in episode 2
  2. 0:21 Only titles are searched
  3. 0:33 search_fields
  4. 0:50 Still nothing
  5. 0:56 update_index
  6. 1:16 Visible, but not searchable
  7. 1:39 get_searchable_content
  8. 2:07 Password-protect a page, then search
  9. 2:20 The generated view leaks private pages
  10. 2:43 The view, rewritten
  11. 2:57 The results template
  12. 3:11 Search in the menu
  13. 3:20 A name from a snippet
  14. 3:27 Commit and tag
  15. 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.

Next: episode 12, Editor experience polish

Carry on from here.

Episode 12 or see all episodes