Django 1.5 to 3.0 strategy

I’ve come into a large project stuck at Django 1.5. The goal is to move this 10 year old project to python3 and a current version of Django 3.x. There is also a desire to do a code audit and dump cruft.

  1. I’m wondering if it would make sense to copy/port code into a fresh install of Django 1.11 then do Python 2.7 → 3.7 and finally follow the minor version upgrades to the target version? similar to what adamchainz suggested in a post about going from 1.8 to current.
  2. Or copy/port django code directly to Django 3.0 and also change python from 2 to 3 at the same time?
  3. would be no copy/paste port and simply do minor versions.

My gut is saying option 1. which is more inline with admanchainz suggestion, but my gut has been known to get things wrong :smiley:
Any discussion on this topic would be a huge help, Thank you in advance!
-Trey

Couple thoughts come to my mind here -

  • The definition of “Large” may be different depending upon whether you’re talking about size of the code base vs amount of data being handled.
  • “Large” for code base is a relative term. To someone who has only worked with the tutorials and other small projects, 1000 lines of code might be considered large. On the other hand, someone working on a project with 25,000 lines of code probably has a different perspective.
    • Also, “large” doesn’t necessarily mean complex.
  • My gut says that the bigger issue isn’t necessarily the amount of code, but the amount of data needing to be migrated. It’s a lot easier to migrate a project if you don’t need to worry about importing the old data.
  • Number, type, and quality of third-party packages may be an issue. If your project is closely tied to an external library that hasn’t been maintained, you need to factor that into your evaluation.

As Ken pointed out, it depends on how big the project is and how much existing data you support. If you don’t care about migrating any data and the app is “mostly” generic views, rebuilding may not be a bad idea.

If you go the upgrade path, go slow and steady one Django version at a time like Django 1.5 to 1.6, then fix things that break. Upgrade to Django 1.7 and keep this pace up. At 1.6 or 1.7, switch from South (assuming they have migrations) to Django’s migration framework. From there, run manage.py check and manage.py migrate as you go, and Django will start to complain pretty loudly.

I would stay on Python 2.7 until after you are done upgrading to Django 1.11. Then switch over to Python 3.7 or 3.8 (you might have to use 3.6) and fix everything that breaks. Then upgrade to 2.0, and you can use any modern Python 3 version you want.

Third-party apps will break and change behavior over that many versions, so you might have to use some forked versions along the way. I typically have to fork a few libraries here and there.

Good luck!