• Stars
    star
    963
  • Rank 47,492 (Top 1.0 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created almost 8 years ago
  • Updated 30 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Next generation Wagtail demo, born in Reykjavik

Wagtail demo project

This is a demonstration project for the amazing Wagtail CMS.

The demo site is designed to provide examples of common features and recipes to introduce you to Wagtail development. Beyond the code, it will also let you explore the admin / editorial interface of the CMS.

Note we do not recommend using this project to start your own site - the demo is intended to be a springboard to get you started. Feel free to copy code from the demo into your own project.

Wagtail Features Demonstrated in This Demo

This demo is aimed primarily at developers wanting to learn more about the internals of Wagtail, and assumes you'll be reading its source code. After browsing the features, pay special attention to code we've used for:

  • Dividing a project up into multiple apps
  • Custom content models and "contexts" in the "breads" and "locations" apps
  • A typical weblog in the "blog" app
  • Example of using a "base" app to contain misc additional functionality (e.g. Contact Form, About, etc.)
  • "StandardPage" model using mixins borrowed from other apps
  • Example of customizing the Wagtail Admin via wagtail_hooks
  • Example of using the Wagtail "snippets" system to represent bread categories, countries and ingredients
  • Example of a custom "Galleries" feature that pulls in images used in other content types in the system
  • Example of creating ManyToMany relationships via the Ingredients feature on BreadPage
  • Lots more

Document contents

Installation

If you want to see what Wagtail is all about, we suggest trying it out through Gitpod. If you want to set up Wagtail locally instead, and you're new to Python and/or Django, we suggest you run this project on a Virtual Machine using Vagrant or Docker (whichever you're most comfortable with). Both Vagrant and Docker will help resolve common software dependency issues. Developers more familiar with virtualenv and traditional Django app setup instructions should skip to Setup with virtualenv.

Setup with Gitpod

Set up a development environment and run this demo website with a single click (requires a Github account):

Open in Gitpod

Once Gitpod has fully started, and a preview of the bakery website has appeared in the "Simple Browser" panel, click the arrow button to the right of the URL bar to open the website in a new tab. Go to /admin/ and login with admin / changeme.

Setup with Vagrant

Dependencies

Installation

Once you've installed the necessary dependencies run the following commands:

git clone https://github.com/wagtail/bakerydemo.git
cd bakerydemo
vagrant up
vagrant ssh
# then, within the SSH session:
./manage.py runserver 0.0.0.0:8000

The demo site will now be accessible at http://localhost:8000/ and the Wagtail admin interface at http://localhost:8000/admin/.

Log into the admin with the credentials admin / changeme.

Use Ctrl+c to stop the local server. To stop the Vagrant environment, run exit then vagrant halt.

Setup with Docker

Dependencies

Installation

Run the following commands:

git clone https://github.com/wagtail/bakerydemo.git
cd bakerydemo
docker compose up --build -d

After this command completes and returns to the command prompt, wait 10 more seconds for the database setup to complete. Then run:

docker compose run app /venv/bin/python manage.py migrate
docker compose run app /venv/bin/python manage.py load_initial_data

If this fails with a database error, wait 10 more seconds and re-try. Finally, run:

docker compose up

The demo site will now be accessible at http://localhost:8000/ and the Wagtail admin interface at http://localhost:8000/admin/.

Log into the admin with the credentials admin / changeme.

Important: This docker-compose.yml is configured for local testing only, and is not intended for production use.

Debugging

To tail the logs from the Docker containers in realtime, run:

docker compose logs -f

Setup with Virtualenv

You can run the Wagtail demo locally without setting up Vagrant or Docker and simply use Virtualenv, which is the recommended installation approach for Django itself.

Dependencies

Installation

With PIP and virtualenvwrapper installed, run:

mkvirtualenv wagtailbakerydemo
python --version

Confirm that this is showing a compatible version of Python 3.x. If not, and you have multiple versions of Python installed on your system, you may need to specify the appropriate version when creating the virtualenv:

deactivate
rmvirtualenv wagtailbakerydemo
mkvirtualenv wagtailbakerydemo --python=python3.9
python --version

Now we're ready to set up the bakery demo project itself:

cd ~/dev [or your preferred dev directory]
git clone https://github.com/wagtail/bakerydemo.git
cd bakerydemo
pip install -r requirements/development.txt

Next, we'll set up our local environment variables. We use django-dotenv to help with this. It reads environment variables located in a file name .env in the top level directory of the project. The only variable we need to start is DJANGO_SETTINGS_MODULE:

cp bakerydemo/settings/local.py.example bakerydemo/settings/local.py
cp .env.example .env

To set up your database and load initial data, run the following commands:

./manage.py migrate
./manage.py load_initial_data
./manage.py runserver

Log into the admin with the credentials admin / changeme.

Next steps

Hopefully after you've experimented with the demo you'll want to create your own site. To do that you'll want to run the wagtail start command in your environment of choice. You can find more information in the getting started Wagtail CMS docs.

Contributing

If you're a Python or Django developer, fork the repo and get stuck in! If you'd like to get involved you may find our contributing guidelines a useful read.

Preparing this archive for distribution

If you change content or images in this repo and need to prepare a new fixture file for export, do the following on a branch:

./manage.py dumpdata --natural-foreign --indent 2 -e auth.permission -e contenttypes -e wagtailcore.GroupCollectionPermission -e wagtailcore.revision -e wagtailimages.rendition -e sessions -e wagtailsearch.indexentry -e wagtailsearch.sqliteftsindexentry -e wagtailcore.referenceindex -e wagtailcore.pagesubscription -e wagtailcore.modellogentry -e wagtailcore.pagelogentry > bakerydemo/base/fixtures/bakerydemo.json
prettier --write bakerydemo/base/fixtures/bakerydemo.json

Please optimize any included images to 1200px wide with JPEG compression at 60%. Note that media/images is ignored in the repo by .gitignore but media/original_images is not. Wagtail's local image "renditions" are excluded in the fixture recipe above.

Make a pull request to https://github.com/wagtail/bakerydemo

Other notes

Note on demo search

Because we can't (easily) use ElasticSearch for this demo, we use wagtail's native DB search. However, native DB search can't search specific fields in our models on a generalized Page query. So for demo purposes ONLY, we hard-code the model names we want to search into search.views, which is not ideal. In production, use ElasticSearch and a simplified search query, per https://docs.wagtail.org/en/stable/topics/search/searching.html.

Sending email from the contact form

The following setting in base.py and production.py ensures that live email is not sent by the demo contact form.

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

In production on your own site, you'll need to change this to:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

and configure SMTP settings appropriate for your email provider.

Testing Content-Security-Policy compliance in Wagtail

Bakerydemo is set up in such a way that it can be used to test Content-Security-Policy compatibility in Wagtail. It uses django-csp to generate the appropriate CSP HTTP header.

By default, django-csp is not enabled since Wagtail isn't fully compatible yet. Set the CSP_DEFAULT_SRC environment variable in your .env file to set the default policy. An example can be found in .env.example.

Users included in demo data

The demo data includes users with different roles and preferences. You can use these users to quickly test the permission system in Wagtail or how localization is handled in the admin interface.

Username Password Superuser Groups Preferred language Timezone Active
admin changeme Yes None undefined undefined Yes
editor changeme No Editors undefined undefined Yes
moderator changeme No Moderators undefined undefined Yes
inactive changeme yes None undefined undefined No
german changeme yes None German Europe/Berlin Yes
arabic changeme yes None Arabic Asia/Beirut Yes

Ownership of demo content

All content in the demo is public domain. Textual content in this project is either sourced from Wikimedia (Wikipedia for blog posts, Wikibooks for recipes) or is lorem ipsum. All images are from either Wikimedia Commons or other copyright-free sources.

More Repositories

1

wagtail

A Django content management system focused on flexibility and user experience
Python
17,837
star
2

django-modelcluster

Django extension to allow working with 'clusters' of models as a single unit, independently of the database
Python
482
star
3

Willow

A wrapper that combines the functionality of multiple Python image libraries into one API
Python
274
star
4

wagtail-localize

Translation plugin for Wagtail CMS
Python
226
star
5

wagtail-bakery

A set of helpers for baking your Django Wagtail site out as flat files.
Python
156
star
6

telepath

A library for exchanging data between Python and JavaScript
Python
139
star
7

wagtail-ai

Get help with your Wagtail content using AI superpowers.
Python
136
star
8

wagtail-autocomplete

An Autocomplete edit handler for selecting Pages, Snippets, and more.
Python
119
star
9

wagtail-personalisation

Rule-based personalisation for Wagtail CMS
Python
117
star
10

wagtail-generic-chooser

A toolkit for custom chooser popups in Wagtail
Python
116
star
11

queryish

A library for constructing queries on arbitrary data sources following Django's QuerySet API
Python
106
star
12

wagtailtrans

A Wagtail add-on for supporting multilingual sites
Python
104
star
13

wagtail-factories

Factory boy classes for wagtail
Python
101
star
14

wagtail-transfer

Content transfer for Wagtail
Python
88
star
15

docker-wagtail-develop

Shell
74
star
16

wagtail.org

Wagtail’s official marketing website
Python
66
star
17

rfcs

Wagtail RFCs
45
star
18

wagtail-review

A Wagtail extension for gathering annotations and feedback on pages before publication
Python
43
star
19

wagtail-airtable

Airtable import and export support for Wagtail pages and Django models.
Python
43
star
20

gsoc

Resources, activity, discussions for Wagtail’s participation to Google Summer of Code
Python
39
star
21

wagtail-live

High speed publishing from messaging apps to a Wagtail live blog. A GSoC 2021 project.
Python
37
star
22

nextjs-loves-wagtail

Tutorial: Next.js ❤️ Wagtail
Python
36
star
23

vagrant-wagtail-develop

A script to painlessly set up a Vagrant environment for development of Wagtail
Shell
36
star
24

wagtail-gitpod

Launch a ready-to-code Wagtail development environment with a single click.
30
star
25

guide

A website to teach Wagtail CMS to content editors, moderators and administrators.
Python
30
star
26

sphinx-wagtail-theme

Sphinx theme for Wagtail
SCSS
29
star
27

wagtail-streamfield-migration-toolkit

Python
25
star
28

wagtail-whoosh

Search backend for Wagtail CMS using Whoosh engine.
Python
24
star
29

outreachy

Resources, activity, discussions for Wagtail’s participation to Outreachy
20
star
30

areweheadlessyet

Are we headless yet?
TypeScript
19
star
31

wagtail-vector-index

Store Wagtail pages & Django models as embeddings in vector databases
Python
18
star
32

cookiecutter-wagtail-package

A cookiecutter template for building Wagtail add-on packages
Python
17
star
33

django-permissionedforms

A Django extension for creating forms that vary according to user permissions
Python
12
star
34

roadmap

Wagtail public roadmap
9
star
35

stylelint-config-wagtail

Shareable stylelint config for CSS and SCSS, following Wagtail’s code style.
JavaScript
9
star
36

wagtail-newsletter

Send email newsletters based on Wagtail content
Python
9
star
37

wagtail-multiple-chooser-panel

An InlinePanel variant allowing multiple items to be quickly selected
JavaScript
7
star
38

wagtail-localize-git

Translate Wagtail content using a git repository and PO files
Python
6
star
39

gitpod-wagtail-develop

Dockerfile
6
star
40

eslint-config-wagtail

Shareable ESLint config for Wagtail, based on airbnb/javascript.
JavaScript
6
star
41

wagtail-review-ui

Frontend UI for adding comments on Wagtail pages
TypeScript
4
star
42

wagtail-editable-help

Make help text editable in the Wagtail admin
Python
3
star
43

wagtail-hallo

Wagtail's legacy Hallo.js richtext editor
Python
3
star
44

accessibility

Documentation relating to accessibility efforts in Wagtail
HTML
3
star
45

workshop

2
star
46

how-to-run-a-wagtail-space

Advice for anyone running a community Wagtail event
2
star
47

gsod

Resources, activity, discussions for Wagtail’s participation to Google Season of Docs
2
star
48

telepath-unpack

JavaScript library for unpacking values that have been packed with telepath
JavaScript
2
star
49

your-first-wagtail-site

The solution for Wagtail’s official getting started tutorial
Python
1
star