Перейти к содержимому

Wagtail Blocks Without Writing Python & Wagtail StreamField Blocks Editable in the Admin

apequaltowork

0:00 / 0:00

Wagtail Blocks Without Writing Python & Wagtail StreamField Blocks Editable in the Admin

83 просмотра · 4 дня назад
apequaltowork
6 подписчиков
83 просмотра · 4 дня назад
Adding a block type to a Wagtail site means editing Python, maybe a migration, a pull request and a deploy — every time, even when the block is a heading and a paragraph. So I built a block builder. You define StreamField blocks in the Wagtail admin by dragging fields around, and they appear as real, selectable blocks in the ordinary page editor — grouped by category, no custom editor screen, no generated files in your repo. This video is in three parts: how the module works, what it looks like to use, and what it renders on the front end. Along the way, the four things that nearly sank it — each of which passed a quick manual test and then turned out to be wrong. It is a content-schema builder, not a page builder. It changes who defines a block's shape; filling the block in is still the editor's job. Code: https://github.com/apequaltowork/wagt... 0:00 Intro 0:04 The problem: a deploy for every block 0:51 What this is not 1:11 Part 1 - Building it 1:16 The whole idea, in two tables 1:38 Why not generate classes with type() 2:06 The local_blocks constructor 2:40 Four things that nearly worked 2:53 Trap 1: the block list goes stale 3:53 Trap 2: migration churn 4:48 Trap 3: blocks rename each other 5:20 Trap 4: Wagtail has no cycle guard 6:34 Part 2 - In the admin 6:53 The builder canvas 7:26 Field types 7:48 Blocks made of other blocks 9:03 They show up in the normal page editor 9:40 Export to Python (the escape hatch) 10:03 Part 3 - On the front end 10:21 The dl problem 10:43 The default renderer 11:04 Three ways to control output 12:13 A bug I found making this video 12:40 What it does not do 13:34 Wrapping up Built with Wagtail 7.4, Django 6.1, Python 3.12. Every code snippet in this video is pasted from the module, and every terminal output is real output from the repo — including the bug I found while screenshotting the front end for this video, which is in there too. I'm considering packaging this as a module people can buy. If that's something you'd use, tell me in the comments what would have to be true for it to be worth it. #Wagtail #Django #Python #CMS #StreamField