Skip to main content

Wagtail CMS Setup Guide

This guide will help you understand how to config Wagtail CMS in SaaS Hammer.

Create Admin

Let's create superadmin, you can skip this step if you already have one.

(venv)$ ./manage.py createsuperuser

And then login on http://127.0.0.1:8000/cms

Setup Site

In the sidebar, click Settings/Sites

You should config the domain and port on production site, so the absoluate URL of the pages would be correct.

On local, you can just change the port to 8000 (this is optional)

Site Settings

We can use Wagtail CMS to help us manage content of the specific sections in Django template. (even the page is served by normal Django view)

The benefit is we can update the content without changing Django template.

In the sidebar, click Settings/Home page Settings

You can add feature and testimonial on this page, after you are done, you can check the result on http://127.0.0.1:8000/

How it works

In Django template, we can iterate to render the content.

{% with features=wagtail_settings.cms.HomePageSettings.features %}
{% for feature in features %}
{% include 'cms/components/home_feature.html' with value=feature.value only %}
{% endfor %}
{% endwith %}

As you can see, with Site Settings, you can use Wagtail to help you manage content of the specific sections in Django template.

To learn more, please check https://docs.wagtail.org/en/latest/reference/contrib/settings.html

Create Pages

Next, please go to http://127.0.0.1:8000/cms/pages/2/, and create pages as children of the Welcome to your new Wagtail site!

The page tree should look like this

/                       Welcome to your new Wagtail site

blog BlogPage
post-page PostPage

contact FormPage

privacy-policy StandardPage
cookies StandardPage

Resources

  1. Wagtail Doc
  2. Build Blog With Wagtail CMS
  3. The Definitive Guide to Next.js and Wagtail