Wagtail Wordpress Import makes it easy to work with the raw data by providing a set of command line tools.
This is a command to help you reduce the amount of data that needs to be parsed and imported.
python manage.py reduce_xml path/to/your/xmlfile.xml
It will remove all items of <wp:comment>
. These xml tags represent comments.
The original file is preserved and a new file is created with -reduced
appended to the file name.
These commands help you analyse the XML data source.
Will generate a table output in the console to show inline styles, HTML tags and shortcodes used in the <content:encoded>
XML tag.
python manage.py analyze_html_content path/to/your/xmlfile.xml
Will generate a JSON file your project which shows the structure of all unique XML tags and attributes.
The file will be saved in the same location and with the same name as the original XML file as a .json
file.
python manage.py analyze_xml_content path/to/your/xmlfile.xml
When testing imports you may need to delete the imported pages and run the import again.
python manage.py delete_imported_pages [app] [page_model]
# app and page_model are required arguments
This script will run until all pages of [app].[model] have been deleted and displays the progress in the console.
WARNING: It will also delete any pages you have created in the Wagtail admin.
To start the Django shell run
python manage.py shell
WARNING: This command is destructive and will delete all images, there's no going back!
from wagtail.images.models import Image
Image.objects.all().delete()
WARNING: This command is destructive and will delete all documents, there's no going back!
from wagtail.documents.models import Document
Document.objects.all().delete()
When running an import you may encounter errors in the console.
If the import starts and stops with the error 'NoneType' object has no attribute '_inc_path'
then you should try running the following command.
python manage.py fixtree
This command scans for errors in your database and attempts to fix any issues it finds.
SQLITE3
If you are testing your import with an sqlite3 database, try to avoid making any changes in the Wagtail admin while a import is running.
The import process executes many save actions as it runs and you will likely create a lock on the database if you try to save updates in the Wagtail admin.
This will prevent the import process from completing a save or update.
Using a postgres or MySQL database avoids this situation.