A template for a Wagtail project with basic apps and a Webpack setup.
- Python 3
virtualenv
orvirtualenvwrapper
- Clone this repo
- Create a new virtualenv for your project and run
pip install django
- Create a new project from the template by running
django-admin startproject <project_name> --template=wagtail-project-template
cd
into your new project directory and rungit init
to initialize a git repository. Make an initial commit.- Open your new project in a text editor and replace all instances of
project_name
with your project name. - Change this README to be relevant to your project.
- Create a database using the instructions below.
- Create a virtualenv for this project (using python3)
pip install -r dev-requirements.txt
- In a new window
npm install
thennpm start
- Start postgresql
createdb <project_name>
DATABASE_URL=postgres:///iai ./manage.py migrate
DATABASE_URL=postgres:///iai ./manage.py createdevdata
DATABASE_URL=postgres:///iai ./manage.py runserver
Use pipenv
to manage requirements.
pipenv install --three
# Creates a virtualenv with python3 and installs normal dependenciespipenv install --dev
# Installs dev dependenciespipenv install <package>
# Installs the package and automatically updatesPipfile
andPipfile.lock
.
The first time you run, you'll need to run migrations and create a superuser:
python manage.py migrate # Create/sync the database.
python manage.py createsuperuser # Create an initial user.
base.py
will use sqlite3 by default.
You can use postgres with the DATABASE_URL
environment variable.
createdb project_name
DATABASE_URL=postgres:///project_name python manage.py migrate
The format for DATABASE_URL
urls is
<type_of_database>://<database_user>:<database_password>@<server>:<port>/<database_name>
If no database is specified, the default is a SQLite database.
You can now run the server: DATABASE_URL=postgres:///project_name ./manage.py runserver
- createdevdata [--delete]
- This command creates a basic Wagtail site and a superuser. It calls all other management commands related to development data. The delete flag deletes all data before creating new data.
- createhomepage [--delete]
- This command creates a homepage and Wagtail Site if they do not already exist. If called with the delete flag, deletes all pages except the root and creates a homepage. You will need to restart the server after running this command, as the Wagtail site number will change.
- createblogposts
- This command creates a blog index page (if it does not already exist) and the specified number of blog posts.