This Django 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.
-
Create a Virtual Environment: Set up a virtual environment to isolate your project dependencies.
pyenv virtualenv 3.8 myproject pyenv activate myproject
-
Install Wagtail: Install the Wagtail CMS package using pip.
pip install wagtail
-
Initialize Project: Use the Django
startproject
command to create a new project based on the Wagtail Starter Kit template.wagtail start myproject --template=<<path or git url>>
-
Navigate to Project Directory: Move into the newly created project directory.
cd myproject
-
Install Project Dependencies: Install the project's dependencies into a virtual environment.
python -m venv venv source venv/bin/activate # For Linux / macOS venv/bin/Activate.ps1 # For Windows pip install -r requirements.txt
All commands from now on should be run from inside the virtual environment.
-
Load Dummy Data: Optionally load in some dummy data, to populate the site with some content.
make load-data
-
Start the Server: Start the Django development server.
make start
-
Access the Site and Admin: Once the server is running, you can view the site at
localhost:8000
and access the Wagtail admin interface atlocalhost:8000/admin
. Log in with the default credentials provided by :- 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, as well as the fly
CLI tool configured locally.
- In the root directory of your project (the one with a
fly.toml
file), runfly launch
- When prompted about copying the existing
fly.toml
file to a new app, choose "Yes". - 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.
- When prompted about copying the existing
- 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"
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.
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
myproject
with{{ project_name }}
3.2. Rename the project directory from
myproject
toproject_name
(without double curly brackets this time).3.3. Wrap template code (
.html
files 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.
Happy coding with Wagtail! If you encounter any issues or have suggestions for improvement, feel free to contribute or open an issue.