Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade django project multiple versions (1.8 to 1.11+)?

I'm upgrading an old project running on Django 1.8 to at least Django 1.11 for LTS. I've heard upgrading a django project multiple versions can be difficult and frustrating. I haven't done this, so my question; is it better to do an upgrade per version, 1.8 -> 1.9 -> 1.10 -> 1.11. Or do you advice me to upgrade straightaway to 1.11 from 1.8. Please leave your best thoughts on this and other things I need to keep in mind while upgrading.

Thanks in advance

like image 555
Vincent Avatar asked Apr 04 '18 13:04

Vincent


People also ask

How do I change Django version in project?

Go to Settings -> Project Interpreter . Double-click the Django package. Activate the check box Specify version and select the version you want.

Is Django 1.11 still supported?

See the How to upgrade Django to a newer version guide if you're updating an existing project. Django 1.11 is designated as a long-term support release. It will receive security updates for at least three years after its release.


1 Answers

The upgrade can be difficult, depends on your situation.

First, check the changelog for every version. The goal here is to understand if there is a major change that can affect your code. For example, the on_delete parameter in the foreign field models was optional, now is mandatory.

If you spot something, just update your code. What can really make the differences are the presence of tests. When we move from python2 to python3 and django 1.7 to 1.11 the tests were our insurance.

We just start to upgrade our code to a different branch using the virtualenv with the new python and new django and just fixing, testing and then merging in develop. If you don't have tests maybe is the right time to write some of them.

I would not suggest you jump directly to django 2.0. Again, if you have tests you can update gradually and then check the deprecation warnings. Those are very helpful to prepare your code for the next version.

Update

During the process, we check our requirements and revise every package we had in our system to verify the compatibility. We clean up a little bit removing some packages and update some others. Again, if you have tests you have your insurance :-)

Conclusion

  • Check the changelogs
  • Use a separate branch

Then:

  1. Update gradually ( e.g. from 1.7 to 1.8)
  2. (write and) Run tests
  3. Update your code/packages
  4. Run tests
  5. If all it's ok then merge back in develop
  6. branch again and go back to 1
like image 77
Karim N Gorjux Avatar answered Oct 26 '22 01:10

Karim N Gorjux