Overview
Theload_initial_data management command loads the complete bakery demo dataset from a fixture file (bakerydemo.json) and copies associated media files to the configured storage backend. This command is essential for setting up a fresh instance of the Wagtail Bakery Demo with sample content.
This command automatically handles both local file storage and cloud storage providers (like AWS S3) by copying media files to the configured
default_storage backend.What It Does
The command performs the following operations in sequence:Copy Media Files
Recursively copies all media files from
bakerydemo/base/fixtures/media/ to the configured storage backend (local filesystem or cloud storage)Clean Default Content
Removes auto-generated Wagtail site and page instances:
- Deletes the default localhost site
- Removes the “Welcome to your new Wagtail site!” page
Load Fixture Data
Loads the complete database fixture from
bakerydemo.json containing:- Page structure (HomePage, Blog, Breads, Locations)
- Snippets (People, Countries, Bread Types, Ingredients)
- Images and documents
- Site configuration
Usage
Command Arguments
This command does not accept any arguments or options.Example Output
Source Code Location
bakerydemo/base/management/commands/load_initial_data.py
Implementation Details
File Storage Handling
The command uses a recursive_copy_files() method to traverse the fixtures media directory:
Fixture Data
The fixture file is loaded from:When to Use
- Initial Setup: When deploying a new instance of the Wagtail Bakery Demo
- Development: Resetting your local development environment to a known state
- Testing: Setting up test environments with consistent sample data
- Demos: Preparing environments for demonstrations or presentations
Related Commands
reset_demo- Completely resets the database and reloads initial datacreate_random_data- Creates additional random test datareset_admin_password- Resets the admin user password

