Creating a Wagtail Export

You can create an initial set of Wagtail pages with theming and images and then export them for loading into another Django portal instance. These can be used to create starter themes or to fully develop a themed set of pages for an Airavata Django Portal.

These steps document how to create one of these exports locally.

Getting Started

  1. Clone and setup the Airavata Django Portal locally. Follow the instructions in the README.md.
  2. Edit your django_airavata/settings_local.py file and add the following at the bottom:
AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend']
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    # Wagtail related middleware
    'wagtail.core.middleware.SiteMiddleware',
    'wagtail.contrib.redirects.middleware.RedirectMiddleware',
]

This allows you to log in locally, without needing to setup Keycloak or have an Airavata backend running.

  1. Create a superuser account. You'll use this to log into wagtail and edit pages:
python manage.py createsuperuser
  1. (Optional) To start from an existing Wagtail export, run python manage.py load_cms_data FILENAME, where FILENAME is the name of one of the Wagtail exports in fixtures directory. For example, you can run
python manage.py load_cms_data default.json
  1. Start the Django server and log in at http://localhost:8000/cms
python manage.py runserver

Creating the Wagtail export

Once you have the pages just the way you want them, you can now export them.

  1. Run the following to export the Wagtail settings into a JSON file in the fixtures directory:
python manage.py dumpdata --natural-foreign --exclude auth.permission \
  --exclude contenttypes --indent 4 > django_airavata/wagtailapps/base/fixtures/myexport.json

Where you can change myexport to whatever you want to meaningfully name the export file.

  1. Commit any media files that were added as part of creating the Wagtail pages.

Resetting your local environment

  1. To start over, first remove (or rename) the database.

Warning

db.sqlite3 stores all of the Wagtail changes you have made. Only remove this if you have already exported the wagtail changes to a file. See the previous section.

rm db.sqlite3
  1. Migrate the database:
python manage.py migrate
  1. Create a superuser account. You'll use this to log into wagtail and edit pages:
python manage.py createsuperuser
  1. (Optional) To start from an existing Wagtail export, run python manage.py load_cms_data FILENAME, where FILENAME is the name of one of the Wagtail exports in fixtures directory. For example, you can run
python manage.py load_cms_data default.json
  1. Start the Django server and log in at http://localhost:8000/cms
python manage.py runserver

Importing a Wagtail export

You can import a Wagtail export by running the following command on a newly created Django instance.

  1. Make sure you have the virtual environment activated.
  2. Run
python manage.py load_cms_data myexport.json

where myexport.json should match the name that you gave the file when exporting it.