Files
zulip/docs/subsystems/django-upgrades.md
rht 41e3db81be dependencies: Upgrade to Django 2.2.10.
Django 2.2.x is the next LTS release after Django 1.11.x; I expect
we'll be on it for a while, as Django 3.x won't have an LTS release
series out for a while.

Because of upstream API changes in Django, this commit includes
several changes beyond requirements and:

* urls: django.urls.resolvers.RegexURLPattern has been replaced by
  django.urls.resolvers.URLPattern; affects OpenAPI code and related
  features which re-parse Django's internals.
  https://code.djangoproject.com/ticket/28593
* test_runner: Change number to suffix. Django changed the name in this
  ticket: https://code.djangoproject.com/ticket/28578
* Delete now-unnecessary SameSite cookie code (it's now the default).
* forms: urlsafe_base64_encode returns string in Django 2.2.
  https://docs.djangoproject.com/en/2.2/ref/utils/#django.utils.http.urlsafe_base64_encode
* upload: Django's File.size property replaces _get_size().
  https://docs.djangoproject.com/en/2.2/_modules/django/core/files/base/
* process_queue: Migrate to new autoreload API.
* test_messages: Add an extra query caused by .refresh_from_db() losing
  the .select_related() on the Realm object.
* session: Sync SessionHostDomainMiddleware with Django 2.2.

There's a lot more we can do to take advantage of the new release;
this is tracked in #11341.

Many changes by Tim Abbott, Umair Waheed, and Mateusz Mandera squashed
are squashed into this commit.

Fixes #10835.
2020-02-13 16:27:26 -08:00

34 lines
1.7 KiB
Markdown

# Upgrading Django
This article documents notes on the process for upgrading Zulip to
new major versions of Django. Here are the steps:
* Carefully read the Django upstream changelog, and `git grep` to
check if we're using anything deprecated or significantly modified
and put them in an issue (and then starting working through them).
Also, note any new features we might want to use after the upgrade,
and open an issue listing them;
[example](https://github.com/zulip/zulip/issues/2564).
* Start submitting PRs to do any deprecation-type migrations that work
on both the old and new version of Django. The goal here is to have
the actual cutover commit be as small as possible, and to test as
much of the changes for the migration as we can independently from
the big cutover.
* Check the version support of the third-party Django packages we use
(`git grep django requirements/` to see a list), upgrade any as
needed and file bugs upstream for any that lack support. Look into
fixing said bugs.
* Look at the pieces of Django code that we've copied and then
adapted, and confirm whether Django has any updates to the modified
code we should apply. Partial list:
* SessionMiddleware in `django.contrib.sessions.middleware` (we fork `get_response`).
* `CursorDebugWrapper`, which we have a modified version of in
`zerver/lib/db.py`. See
[the issue for contributing this upstream](https://github.com/zulip/zulip/issues/974)
* `PasswordResetForm` and any other forms we import from
`django.contrib.auth.forms` in `zerver/forms.py` (which has all of
our Django forms).
* Our AsyncDjangoHandler class has some code copied from the core
Django handlers code; look at whether that code was changed in
Django upstream.