upgrade-version.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. ===================================
  2. Upgrading Django to a newer version
  3. ===================================
  4. While it can be a complex process at times, upgrading to the latest Django
  5. version has several benefits:
  6. * New features and improvements are added.
  7. * Bugs are fixed.
  8. * Older version of Django will eventually no longer receive security updates.
  9. (see :ref:`backwards-compatibility-policy`).
  10. * Upgrading as each new Django release is available makes future upgrades less
  11. painful by keeping your code base up to date.
  12. Here are some things to consider to help make your upgrade process as smooth as
  13. possible.
  14. Required Reading
  15. ================
  16. If it's your first time doing an upgrade, it is useful to read the :doc:`guide
  17. on the different release processes </internals/release-process>`.
  18. Afterwards, you should familiarize yourself with the changes that were made in
  19. the new Django version(s):
  20. * Read the :doc:`release notes </releases/index>` for each 'final' release from
  21. the one after your current Django version, up to and including the version to
  22. which you plan to upgrade.
  23. * Look at the :doc:`deprecation timeline</internals/deprecation>` for the
  24. relevant versions.
  25. Pay particular attention to backwards incompatible changes to get a clear idea
  26. of what will be needed for a successful upgrade.
  27. Dependencies
  28. ============
  29. In most cases it will be necessary to upgrade to the latest version of your
  30. Django-related dependencies as well. If the Django version was recently
  31. released or if some of your dependencies are not well-maintained, some of your
  32. dependencies may not yet support the new Django version. In these cases you may
  33. have to wait until new versions of your dependencies are released.
  34. Installation
  35. ============
  36. Once you're ready, it is time to :doc:`install the new Django version
  37. </topics/install>`. If you are using virtualenv_ and it is a major upgrade, you
  38. might want to set up a new environment with all the dependencies first.
  39. Exactly which steps you will need to take depends on your installation process.
  40. The most convenient way is to use pip_ with the ``--upgrade`` or ``-U`` flag:
  41. .. code-block:: bash
  42. $ pip install -U Django
  43. pip_ also automatically uninstalls the previous version of Django.
  44. If you use some other installation process, you might have to manually
  45. :ref:`uninstall the old Django version <removing-old-versions-of-django>` and
  46. should look at the complete installation instructions.
  47. .. _pip: http://www.pip-installer.org/
  48. .. _virtualenv: http://www.virtualenv.org/
  49. Testing
  50. =======
  51. When the new environment is set up, :doc:`run the full test suite
  52. </topics/testing/overview>` for your application. In Python 2.7+, deprecation
  53. warnings are silenced by default. It is useful to turn the warnings on so they
  54. are shown in the test output (you can also use the flag if you test your app
  55. manually using ``manage.py runserver``):
  56. .. code-block:: bash
  57. $ python -Wall manage.py test
  58. After you have run the tests, fix any failures. While you have the release
  59. notes fresh in your mind, it may also be a good time to take advantage of new
  60. features in Django by refactoring your code to eliminate any deprecation
  61. warnings.
  62. Deployment
  63. ==========
  64. When you are sufficiently confident your app works with the new version of
  65. Django, you're ready to go ahead and :doc:`deploy </howto/deployment/index>`
  66. your upgraded Django project.
  67. If you are using caching provided by Django, you should consider clearing your
  68. cache after upgrading. Otherwise you may run into problems, for example, if you
  69. are caching pickled objects as these objects are not guaranteed to be
  70. pickle-compatible across Django versions. A past instance of incompatibility
  71. was caching pickled :class:`~django.http.HttpResponse` objects, either
  72. directly or indirectly via the :func:`~django.views.decorators.cache.cache_page`
  73. decorator.