Migrating your Drupal content to Wagtail

Time to migrate… Photo by Kenrick Mills on Unsplash

Understanding what we need to do

  1. Create a Drupal view to give us an idea of how much content we are dealing with, listing node types and counts.
  2. Create a mapping sheet to understand the differences between each content type in Drupal and Wagtail.
  3. Export the Drupal node data.
  4. Run a python script to programatically create content using the Drupal data export.
Drupal to Wagtail migration mapping example

Importer classes

Django management commands

Photo by Tim Easley on Unsplash

Producing the Drupal source data

Our source article content type in Drupal
The JSON export for the node data

Tips

  • To change the label value in the JSON change the views format settings.
  • Depending on your core version, you might need to append your URL, e.g: news/export?format_json when viewing that actual page, not in the view path itself
  • For images and files, you’ll want to add a relationship to the view
A Drupal article node in JSON
Moving — Photo by Josh Edgoose on Unsplash

Moving Time

  • legacy_id and legacy_url will some in handy when checking if the content already exists and creating a url slug.
wagtailmigration/data_migration/
├── data
│ └── news.json # our exported JSON data
├── importers
│ ├── base.py # Base importer class
│ ├── __init__.py
│ └── news.py # The news importer (inherits base importer)
├── __init__.py
├── management
│ ├── commands
│ │ ├── base.py # Base class for importing file into Wagtail
│ │ ├── import_news.py # Specific import managment for news
│ │ └── __init__.py
│ └── __init__.py
└── README.md # Instructions for running

How we are going to actually run the code

/manage.py [importer] [parent_page_id] [data_file.json]/manage.py import_news 4 wagtailmigration/data_migration/data/news.json

commands/import_news.py

importers/news.py

Summary

Thank you to

--

--

--

Developer, I also make art and listen to techno https://www.kevinhowbrook.com/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

But What About Performance and Size?

Hackster’s Handpicked Projects of the Week

{UPDATE} Digi Evolution Hack Free Resources Generator

antiX Linux

Create texture to the material

(+1–866–235–8555)Fix Avast UI failed to load

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kevin howbrook

Kevin howbrook

Developer, I also make art and listen to techno https://www.kevinhowbrook.com/

More from Medium

Headlines at your fingertips: Today in Tabs

System administrator to Developer

How to Create an App like Yelp: Useful Tips

Amazing Tool Every iOS / Android Developer Should Use!