This project template is designed for creating Wagtail builds quickly, intended for developers to bootstrap their Wagtail site development using wagtail start --template=. The template comes with pre-defined pages, blocks, functionalities, and fixtures to streamline the initial setup process.
Check that you have an appropriate version of Python. You want to make sure that you have a compatible version installed:
python --version
# Or:
python3 --version
# On Windows you may want to use py.exe:
py --versionYou can replace myproject with your preferred project name.
mkdir myproject
cd myprojectpython -m venv .venv
source .venv/bin/activatepy -m venv .venv
.venv\Scripts\activateInstall the Wagtail CMS package using pip:
pip install wagtailUse the Wagtail Starter Kit to generate a new project. Here again, you can replace myproject with your preferred project name. The project name chosen here will be used throughout the generated code.
wagtail start --template=https://github.com/wagtail/news-template/archive/refs/heads/main.zip myproject .Run the bootstrap command to install project dependencies and set up the development environment:
python bootstrap.pyThis command will:
- Install project dependencies
- Run database migrations
- Create the cache table
- Load sample content
- Create the default administrator account
- Collect static files
If you prefer to start with a clean project without demo content:
python bootstrap.py --no-sample-dataThis skips loading the sample content and default administrator account.
To create an administrator account manually, run:
python manage.py createsuperuserpython manage.py runserverOnce the server is running:
- Site: http://localhost:8000
- Admin: http://localhost:8000/admin/
If sample content was loaded, you can log in with:
- Username:
admin - Password:
password
Once you have your own copy of the template, you can extend and configure it however you like.
To get it deployed, follow the instructions below for your hosting provider of choice.
Don't see your preference here? Contributions are always welcome!
Before you can deploy to fly.io, you will need an account and the fly CLI tool will need to be installed on your machine.
- In the root directory of your project (the one with a
fly.tomlfile), runfly launch- When prompted about copying the existing
fly.tomlfile to a new app, choose "Yes".
- When prompted about copying the existing
Caution
Choosing "No" (the default) here will result in a broken deployment, as the fly.toml file requires configuration needed for the project to run correctly.
- When prompted about continuing the setup in the web UI, or tweak the generated settings, choose "No".
- The "Region" will be selected automatically. If you wish to change this, choose "Yes" instead, and modify the region in the browser.
- Once the launch is successful, you'll need to generate a secret key
- This can be done using
fly secrets set SECRET_KEY=<key>, or through the web UI.
- This can be done using
- Finally (optional), load in the dummy data, to help get you started
fly ssh console -u wagtail -C "./manage.py load_initial_data"
Note
If you receive "error connecting to SSH server" when running the above command, It likely means the fly.toml above wasn't picked up correctly. Unfortunately, you'll need to delete your application and start again, resetting the changes to the fly.toml file.
If the error still persists, check the application logs.
You can now visit your wagtail site at the URL provided by fly. We strongly recommend setting strong password for your user.
The database and user-uploaded media are stored in the attached volume. To save costs and improve efficiency, the app will automatically stop when not in use, but will automatically restart when the browser loads.
Easily deploy your application to Divio Cloud using the steps below:
-
Getting Started Follow the Getting Started instructions to set up your project locally.
-
Push Your Repository Upload your project to GitHub or another Git provider.
-
Create a New Application Log in to the Divio Control Panel and create a new application and
- Choose "I already have a repository.".
- Connect your Git provider and proceed by clicking "Next.".
- Give your application a suitable name and select the "Free Trial" plan, then click "Create application.".
Your application will be created with two environments: Test and Live.
-
Add a Database service From the Services view of your application, add a database service.
-
Deploy Your Application From the "Environments" view, click "Deploy" on the Test environment. Once the deployment completes, access your site using the "Env URL" link.
-
Additional Configuration Migrations and Environment Variables:
To automatically run migrations on every deployment, add a "Release command" within the Settings section of your application with the value
python manage.py migrate. You can add additional commands as needed.Use the Env Variables section to set variables such as
SECRET_KEY(generator) for the test and live environments.Media Storage: From the Services view of your application, add an object storage to store user-uploaded files.
To customize this template, you can either make changes directly or backport changes from a generated project (via the wagtail start command) by following these steps:
-
Create a new project using the provided instructions in the Getting Started section.
-
Make changes within the new project.
-
Once you've completed your changes, you'll need to copy them over to the original project template, making sure to:
3.1. Replace occurrences of
myprojectwith{{ project_name }}3.2. Rename the project directory from
myprojecttoproject_name(without double curly brackets this time).3.3. Wrap template code (
.htmlfiles under the templates directory), with a verbatim tag or similar templatetag to prevent template tags being rendered onwagtail start(see django's rendering warning). -
Update compiled static assets using
npm run build:prod. -
Update fixtures using
make dump-data
Make sure to test any changes by reviewing them against a newly created project, by following the Getting Started instructions again.
There are several tools you can use to verify a generated project works as expected after making changes to the template:
-
Django system check (validates settings and models):
python manage.py check
-
Run unit tests:
python manage.py test -
Run tests with warnings enabled (see advice in Django docs):
python -Wa manage.py test -
Smoke test: After loading the sample data, run the development server
python manage.py runserver
then visit http://localhost:8000 and http://localhost:8000/admin/ to confirm the site and admin load.
Please install the project's pre-commit hooks:
pre-commit installRun the linting checks before submitting a pull request:
pre-commit run --all-filesThis helps catch formatting and linting issues locally before the CI checks run.
Happy coding with Wagtail! If you encounter any issues or have suggestions for improvement, feel free to contribute or open an issue.