Check if all the packages are upgradable.
Check the version support table for python, django, and wagtail
Gochas:
wagtail elasticsearch 1.x. You’ll have to upgrade it before you make the switch.wagtail API 1.x. It’s also been removed and if upgrading isn’t possible you can use wagtailapi_legacy. Warnings:
The biggest trick is that you do not work in the current virtual environment (assume that you are using a virtual environment, and please do so if not). You should start a new environment with python 3 preinstalled so that you don't have to manually uninstall and install different versions of python.
mkvirtualenv env_name --python=python3After switch to Python 3, we have to deal with the changes:
print has become a function in python 3from six import u as unicode # Fix Python 2.x. fixes all the issues with unicodeRun the website and fix all the errors\warnings, and then go to the next step
django-admin makemigrations and django-admin migrate to make sure your database is up-to-dategit checkout python_upgrade_3pip install -r dev.txtdjango-admin migrate (you must migrate first for the project to run)django-admin runserver should workgit checkout wagtail_django_upgradepip freeze | xargs pip uninstall -y to delete all the packages firstpip install -r dev.txt to re-install all the packages (the quickest way to get all the upgraded packages working)add2virtualenv thirdparty_apps (if any packages are not maintained and you have to upgrade them locally)django-admin migratedjango-admin runserver should workYou should upgrade django one version at a time and fix everything during upgrading until you are at 1.11. Chances are that the upgrade is much smoother to Django 2.0 if the project was built in 1.11.
After you are at Django 1.11 (or at least very close to this version) and before continuing, make sure the site doesn't have any missing migrations and you have made a backup of the database (just incase shit hits the fan).
django-admin makemigrations to check if there is any migration changesdjango-admin migrate to actually make the migration happens at the database levelSquash every apps migrations and make sure to use the last migration number.
django-admin squashmigrations pages 0032Delete all migration files except for the squashed ones.
Before doing the actual upgrading, double check that you are at (or at least close to) Django 1.11 and wagtail 1.13 as we mentioned before
Start upgrading the main ones:
pip3 install django==2.*pip3 install wagtail==2.*pip3 install djangorestframework==3.7.7Next, run the wagtail module update script. This will rename any old imports to the new ones.
wagtail updatemodulepaths --list Will list the files getting changed.wagtail updatemodulepaths --diff Will show the diffs.wagtail updatemodulepaths Will make the all changes.If this doesn't work and gives you a unicode error. Wait a bit a run it again. I noticed docker takes some time to switch to django 2.
MIDDLEWARE_CLASSES name to MIDDLEWARE in all the settingsDjango 2 made some changes to how urls and namespacing works. Known quick changes are:
url(r'^clientadmin\', include(admin.site.urls)), to url(r'^clientadmin\', admin.site.urls),Also make sure to add app_name to included urls that are namespaced. So if you see url(r'^forms\', include(snippetforms_urls, namespace="forms")), make sure apps\cms\snippetforms\urls.py is updated to have app_name = 'forms'
unicode mess, instead it only has the str type which saves a lot headache. In the django models, change all the __unicode__ to __str__ and it'll correct all the display issueassignment_tag and is used in most of our template tags (blog, menu & pages). Do a quick find all and replace it to simple_tag.process_request and process_response by default. This functionally has been replaced with call and the get_response function that is passed to init.
'ManyToManyField' object has no attribute 'rel', it is possible due to the fact that db_field.rel is deprecated, just change it to db_field.remote_field