Wagtail Unboxed episode 03 5:08
The page model and the tree
We finally change code: two fields on the homepage, a second page type, and the one migration line that explains how every Wagtail page is stored.
What this episode covers
Last episode predicted that a page one level under Home would get the tree path 000100010001. This episode we build that page and check it in the database.
Along the way: adding fields to a Wagtail page, and why they do not appear in the admin without content_panels; creating a second page type, StandardPage, and why it needs its own template; and multi-table inheritance, where every page lives in two tables joined by page_ptr.
Also covered: reading the page tree from the shell, why url_path says /home/about/ while the page is served at /about/, and the .specific gotcha, where Page.objects hands you a page with your fields missing.
Chapters
- 0:00 Last episode's prediction
- 0:19 Where we left HomePage
- 0:38 Adding intro and body fields
- 0:56 A field is not a form field: content_panels
- 1:17 A second page type: StandardPage
- 1:31 Every page type needs a template
- 1:54 makemigrations and migrate
- 2:02 The page_ptr line
- 2:15 Every page lives in two tables
- 2:45 Editing the homepage in the admin
- 2:56 Adding a child page
- 3:08 Printing the tree
- 3:14 The prediction checks out
- 3:31 url_path is not the URL
- 3:59 Why is my field missing? .specific
- 4:20 What's still wrong
- 4:38 Commit and tag
- 4:46 Next episode
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.