Ashish Pitrodafield notes
All episodes

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

  1. 0:00 Last episode's prediction
  2. 0:19 Where we left HomePage
  3. 0:38 Adding intro and body fields
  4. 0:56 A field is not a form field: content_panels
  5. 1:17 A second page type: StandardPage
  6. 1:31 Every page type needs a template
  7. 1:54 makemigrations and migrate
  8. 2:02 The page_ptr line
  9. 2:15 Every page lives in two tables
  10. 2:45 Editing the homepage in the admin
  11. 2:56 Adding a child page
  12. 3:08 Printing the tree
  13. 3:14 The prediction checks out
  14. 3:31 url_path is not the URL
  15. 3:59 Why is my field missing? .specific
  16. 4:20 What's still wrong
  17. 4:38 Commit and tag
  18. 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.

Next: episode 04, Templates and static files

Carry on from here.

Episode 04 or see all episodes