Description: https://images.manning.com/360/480/resize/book/e/052ae88-24b1-4d1c-961d-463e9bca8f15/Tauilen-MEAP-HI.png

An excerpt from Wagtail CMS in Action by Kalob Taulien

The article gives an overview of Wagtail CMS, whether or not it’s right for you, and how this book will teach you to use it.

Read it if you’re interested in Wagtail CMS or content management systems.


Take 25% off Wagtail CMS in Action by entering fcctaulien into the discount code box at checkout at manning.com.


Wagtail CMS is a very popular content management system for managing your website content, based on Python and Django. Wagtail allows your team to do what each team member does best, whether that’s coding, site administration, or writing and publishing content. Everybody on a team has certain strengths that can be maximized when using a content management system that specializes in dedicated team roles. For example, someone who specializes in writing content can do just that without worrying about breaking the website or having to manage any code. Likewise, developers can focus on writing high quality code and not have to worry about writing great content. The benefit is that everybody gets to do the job they want to do, the job they are particularly good at, and your website can operate in its most efficient form.

Wagtail CMS, or just Wagtail, is an open source content management system designed for modern workflows and modern teams. At a high level, Wagtail is used to control the content of your website such as written paragraphs, images, documents, pages, and reusable pieces of data called snippets.

On the surface it seems that Wagtail is the same as every other content management system, but once you dive into the specifics you’ll realize it has a lot of amazing features that will enable your team to be more productive and enjoy their jobs, without the ability to accidentally break your website.

That’s why companies like Google, Twilio, The Motley Fool, Mozilla, and NASA are using Wagtail.

What is a content management system?

Now, at this point you might wonder, “What is a content management system?” A content management system, or CMS for short, is a suite of tools and features that help you maintain a website, along with the written content, images, videos, documents and anything else that might be needed to create well thought out pages. Basically, a CMS makes it easier for you to manage your website. If you’ve ever read a blog or visited a news website, chances are good that they are using a content management system to help them build beautiful web pages, write appealing content, and maintain their branded designs. You have hundreds, if not thousands, of CMSes to choose from, and Wagtail CMS is a top contender for most organizations.

Another common question I hear is, “What should a good CMS do?” This is the golden question that separates Wagtail from other content management systems, like WordPress, which you surely have heard of as a web developer.

A good CMS should, in all honesty, not do everything. It’s like that old saying from Aesop’s Fables, “Those who seek to please everybody please nobody”. And in terms of content management systems, it can be rephrased like this: If you can do it all, you’re not doing anything well.

What makes Wagtail different?

This is where Wagtail shines. Although Wagtail has features for everybody, it doesn’t grant any lone person total system control. Instead, Wagtail wants you and your team to do what you all do best. Whether that’s writing (editing), SEO, coding, design, site administration, or anything else—Wagtail wants you to leverage your skills. The idea is that, with a good CMS, you are using all the top talent from your team. Or if you’re a single-person team, then you should be wearing different hats at different times and not trying to do it all at the exact same time.

Throughout the book I assume that you work with a team where each person has a specific role or a small handful of roles, but if you don’t work in a team then let’s assume you’ll be performing every role at different times. For instance, you might be writing a blog post but then decide you need to make an enlarged quote area to quote your favorite author. Then you do some coding (wearing the coder hat), deploy your changes (DevOps hat), and continue writing your blog post (editing hat).

With Wagtail you get to focus on each role one at a time. If you’re editing content or writing some new content, you can simply focus on writing interesting content. There’s no need to be thinking about coding or design. You’re most likely a web developer if you’re reading this book, so you can focus purely on coding and giving your editors the best experience possible while keeping your designers happy because the site can’t easily be broken out of its pre-formatted design.

Context switching

Why is this such a powerful concept to adopt? Well, the short answer is context switching, which is when you change tasks and all of a sudden you’re wasting time trying to remember where you left off and spending more time getting back into “the zone”. It’s hard to quantify but it absolutely does exist. Think of it like this: you sleep for at least 8 hours, hopefully, and then immediately wake up and go for a run. And when you’re done running, you immediately go back to bed and sleep some more. You’ll be far too tired, or too awake, to switch context, so you’ll end up running slower, or lying in bed doing nothing. That’s context switching in an extreme example. And it happens to developers all the time.

This is where Wagtail steps in and says, “Just focus for the moment on what you do best”. If something else comes up, you need to purposely change context, making yourself aware of what you need to do, and being able to focus on one task at a time, which often leads to better decision making and, in this case, a functional website that looks and acts perfectly.

As a web developer, you likely want to focus on coding and not worry too much about other tasks such as design, content, or site administration. If that sounds like you, then good news is headed your way! Wagtail is probably the content management system for you based on that sentence alone. But allow me to continue trying to convince you that Wagtail is the right solution for you or your organization.

People, especially those who work in teams (or wear multiple hats), get excited about Wagtail websites because they can focus on a single task. You can channel your inner programmer to write the cleanest code possible without making your website feel complicated or overengineered while maintaining all the features and power you need to create a modern website. Wagtail is built on top of one of the world’s most famous web frameworks, called Django. And Django is built on top of the world’s most popular programming language: Python.

Wagtail and Django

Wagtail is built on top of an existing web framework (Django), the lines between what is Wagtail and what is Django can be blurry at times. Throughout the book, however, you’ll come to be able to discern the difference. But also keep in mind that it’s not a crucial subject to understand: you don’t need to know the difference between Wagtail and Django; it won’t make you a better developer—though it might help ease some of the initial confusion.

The figure below shows how Wagtail and Django interact. The left side of the figure shows what Wagtail is doing, or trying to do. On the right, we see what Django is up to.


Figure 1. Shows the intricate interaction between Django and Wagtail. Because Wagtail cannot exist without Django, the lines between their activities can be blurry.


The two sided figure demonstrates how Wagtail and Django cooperate with each other, and which system is responsible for particular tasks. It will look big and scary at first, but as you progress through the book it will make more sense.

At the end of the day, most of the code you write will interact with Django somehow. You might not see it, and it might not be immediately obvious, but that’s how frameworks tend to work. And with Wagtail, specifically, there’s a lot of back-and-forth with Django. If this concerns you, it shouldn’t. Django is a very powerful and mature framework used by Instagram, Pinterest, Dropbox and tons of other huge organizations. It’s reliable, well-built, open source, and tested. Because of its maturity, not everything needs to be reinvented. Like the templating system, it’s an advanced feature that is hard to re-create and that works perfectly fine, so there’s no need for Wagtail to use its own. Instead, it can leverage what Django offers and layer additional features on top.

Now, let’s talk about the core pillars of Wagtail. Pages are absolutely vital in a content management system. But snippets, images/documents, reports and site settings also help a Wagtail page become its best self, so to speak. For instance, if a page has a user-uploaded image, Wagtail will need to know the relationship between that image and the page so the templating engine can understand what is going on. If that was a mind-melting statement – don’t give up yet! It’s my job to make this concept as easy to understand as humanly possible—and I’m going to do just that throughout the book.

What you will learn in this book

If you’re still with me at this point, let’s talk about what you will learn in this book, and how you will learn it.

Together you and I will set up a new Wagtail website from scratch, create a simple blog that will introduce you to the Wagtail way of coding, and then create a functional, real-life e-commerce store. Lastly, you will deploy this website to the web on our own server. The goal is to use a real life example of when you would create a Wagtail website, and I don’t assume that you know anything about Wagtail, so we’ll start from scratch. Our website will touch on the most common features of Wagtail and teach you some Django along the way. I’ll start each chapter with an example and then integrate the concept of the example into a working codebase. I will share the source code on GitHub for each chapter as well, so you won’t need to write all the code by hand.

Is this book for you?

Now, I’d like to talk about whether this book is for you. You and I will write a fair amount of code and spend quite a bit of time together, so I want to make sure Wagtail CMS in Action is for you. I am making a few assumptions throughout this book, like the assumption that you know simple Python OOP. You don’t need to know about databases or web requests, and anything outside of standard Python I will do my best to explain to you along the way (like deploying a website). If you are a developer who knows some Python, this book is absolutely for you. Or if you’re a manager trying to decide if Wagtail is for you and your organization, this book will help you understand whether Wagtail is a good fit. However, if you’re not code-inclined whatsoever, or you’d rather create a website in an afternoon by clicking some boxes, then Wagtail won’t work well for you either (at least not at this very moment).

Want to learn more? Check out the book here.