How do i migrate data from wordpress database to django database.

In part this depends upon how close the original WordPress database matches what you’re looking to use in Django.

In general, when we’re migrating data from a different system into Django, we do the following:

  • Create a definition in DATABASES for the original database
  • Create an app with a name representing the original system
  • Use inspectdb to create models from the original database for that new app
  • Fix and adjust those created models as necessary.
  • Create a set of Django manage commands to create the data from the original database for the new Django system.

By building models for the existing data, we can then do more sophisticated translations than just “copy data from table ‘A’ to table ‘B’”. We can write code to do processing on individual rows, manage foreign key and many-to-many relationships, restructure data, etc.

Whether you need to do something as comprehensive as this depends upon what might need to be done to the existing data to make it work with the new database.

There is a generic class of products known as “ETL” - “Extract, Transform, Load”, that are designed to facilitate operations like this. They’re ok in the more basic cases, but once you get beyond the simpler situation you can quickly encounter limitations that prevent you from doing what needs to be done.

1 Like