Ashish Pitrodafield notes
All episodes

Wagtail Unboxed episode 04 5:38

Templates and static files

The teal egg finally goes. We delete Wagtail's welcome page, write a real base template, list child pages from the page tree, and style the site with plain CSS.

What this episode covers

Where the welcome page lives and how to delete it properly; how Wagtail finds a template from the model name, and the two places templates can live; and a real base.html with a header, main and footer, keeping the generated bits that are worth keeping.

Then the template work itself: pageurl, slugurl and the richtext filter, why you should never build links from url_path, and listing child pages with get_children.live straight from the page tree.

Plus the ten-minute trap nobody warns you about: you write your CSS, reload, and the page is still completely unstyled — with nothing wrong with your code. We cover why studio.css ships at 0 bytes, how {% static %} resolves it, and the browser-cache trap, with proof of what is actually happening.

No build step, no framework, no Node. Plain CSS, hand-written, for the whole series.

Chapters

  1. 0:00 Four episodes in, still an egg
  2. 0:16 Where the welcome page lives
  3. 0:30 How Wagtail finds a template
  4. 0:46 Two places templates live
  5. 1:06 base.html — keep the head
  6. 1:23 Header, main, footer
  7. 1:35 pageurl, slugurl, richtext
  8. 1:58 Never build links from url_path
  9. 2:14 Listing child pages from the tree
  10. 2:32 The stylesheet that ships empty
  11. 2:56 static and STATICFILES_DIRS
  12. 3:14 You write the CSS. Nothing changes.
  13. 3:30 What's actually happening
  14. 3:52 Hard-reload
  15. 4:09 The result
  16. 4:22 The About page
  17. 4:36 One media query
  18. 4:50 Why the 404 page hasn't changed
  19. 5:09 Commit and tag
  20. 5:12 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 05, StreamField, properly

Carry on from here.

Episode 05 or see all episodes