3

There are a million records in our old CMS system. Now we want to migrate the old data to Wagtail. How to import these data? I know I have to create a model to store the data, but how to import the records to the model tables in Wagtail? Should I insert these records into the MySql database immediately? Or use some APIs or functions of wagtail?

Thanks very much.

beibeitu
  • 164
  • 7
  • Take a look at my answer here: https://stackoverflow.com/a/52411849/5548239. Django's `inspectdb` will give you a head start on creating models for the old database. – Dan Swain May 08 '20 at 13:30
  • Thanks for your reply. But I don't think that inspected is what I am looking for. We want to create a new model to handle these. I just want to create a new model in Wagtail, then import the old data by some scripts. Perhaps I can insert these records into the model table, but how to update the ES index? I just want to use Elasticsearch as my search engine. – beibeitu May 08 '20 at 14:01

1 Answers1

3

I have taken the following approach several times when migrating complicated Drupal sites to Wagtail:

  1. Export the legacy content in some format that I can easily manipulate with python. (The Drupal sites I worked with generated CSV exports, but you could just as easily work with JSON or XML; whatever you can get your old system to spit out.)

  2. Write a Django management command that parses your export and creates Wagtail page objects. I found these instructions helpful, though at step 4 I do page.save_revision().publish() instead of just page.save().

You've got a lot more records than I ever dealt with, so perhaps you'd find it easier to skip step 1 and query your old db directly in the management command.

matthewn
  • 149
  • 1
  • 6