From 1d9fb4f9881c687ea4007ea2e44fd16807360e50 Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Sat, 1 May 2021 15:34:59 +0200 Subject: [PATCH] django: Upgrade Zulip to Django 3.2 LTS. This is a straightforward upgrade in terms of changes needed. Necessary changes were: - Set `DEFAULT_AUTO_FIELD` https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-auto-created-primary-keys - `The default_app_config application configuration variable is deprecated, due to the now automatic AppConfig discovery.` https://docs.djangoproject.com/en/3.2/releases/3.2/#automatic-appconfig-discovery To handle this one, we can remove default_app_config from zerver/__init__.py because it satisfies what release notes describe in https://docs.djangoproject.com/en/3.2/releases/3.2/#automatic-appconfig-discovery: "Most pluggable applications define an AppConfig subclass in an apps.py submodule. Many define a default_app_config variable pointing to this class in their __init__.py. When the apps.py submodule exists and defines a single AppConfig subclass, Django now uses that configuration automatically, so you can remove default_app_config." An important note is that rebuild-test-database needs to be run after this upgrade in dev environment - if tests are run with test db that was built on the previous version, they will fail due to a mysterious bug (?), where changing attributes of a user and .save()ing after logging in in the test via self.login_user, causes getting logged out - the next requests via self.client_get etc. are unauthed for some reason, unless self.login_user is called again. This behavior is no longer exhibited upon rebuilding the test db - and I can't reproduce it in production or dev db. So this can likely be reasonably dismissed as some quirk of the test client system that won't be relevant in the future and doesn't impact production. --- requirements/common.in | 2 +- requirements/dev.txt | 6 +++--- requirements/prod.txt | 6 +++--- tools/test-backend | 1 - version.py | 2 +- zerver/__init__.py | 2 -- zproject/computed_settings.py | 2 ++ 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/requirements/common.in b/requirements/common.in index af5cb3739c..b18b3cb597 100644 --- a/requirements/common.in +++ b/requirements/common.in @@ -3,7 +3,7 @@ # and requirements/prod.txt. # See requirements/README.md for more detail. # Django itself -Django[argon2]==3.1.* +Django[argon2]==3.2.* # needed for Literal, TypedDict typing-extensions diff --git a/requirements/dev.txt b/requirements/dev.txt index b462254634..e04e1b279d 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -380,9 +380,9 @@ django-two-factor-auth[call,phonenumberslite,sms]==1.13.1 \ --hash=sha256:a20e03d256fd9fd668988545f052cedcc47e5a981888562e5e27d0bb83deae89 \ --hash=sha256:d270d4288731233621a9462a89a8dfed2dcb86fa354125c816a89772d55f9e29 # via -r requirements/common.in -django[argon2]==3.1.8 \ - --hash=sha256:c348b3ddc452bf4b62361f0752f71a339140c777ebea3cdaaaa8fdb7f417a862 \ - --hash=sha256:f8393103e15ec2d2d313ccbb95a3f1da092f9f58d74ac1c61ca2ac0436ae1eac +django[argon2]==3.2 \ + --hash=sha256:0604e84c4fb698a5e53e5857b5aea945b2f19a18f25f10b8748dbdf935788927 \ + --hash=sha256:21f0f9643722675976004eb683c55d33c05486f94506672df3d6a141546f389d # via # -r requirements/common.in # django-auth-ldap diff --git a/requirements/prod.txt b/requirements/prod.txt index 1ba4de9ac1..daea305c04 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -244,9 +244,9 @@ django-two-factor-auth[call,phonenumberslite,sms]==1.13.1 \ --hash=sha256:a20e03d256fd9fd668988545f052cedcc47e5a981888562e5e27d0bb83deae89 \ --hash=sha256:d270d4288731233621a9462a89a8dfed2dcb86fa354125c816a89772d55f9e29 # via -r requirements/common.in -django[argon2]==3.1.8 \ - --hash=sha256:c348b3ddc452bf4b62361f0752f71a339140c777ebea3cdaaaa8fdb7f417a862 \ - --hash=sha256:f8393103e15ec2d2d313ccbb95a3f1da092f9f58d74ac1c61ca2ac0436ae1eac +django[argon2]==3.2 \ + --hash=sha256:0604e84c4fb698a5e53e5857b5aea945b2f19a18f25f10b8748dbdf935788927 \ + --hash=sha256:21f0f9643722675976004eb683c55d33c05486f94506672df3d6a141546f389d # via # -r requirements/common.in # django-auth-ldap diff --git a/tools/test-backend b/tools/test-backend index 233ec37cb5..3c0b8df982 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -76,7 +76,6 @@ not_yet_fully_covered = [ "zerver/lib/markdown/help_relative_links.py", "zerver/lib/markdown/nested_code_blocks.py", # Other lib files that ideally would coverage, but aren't sorted - "zerver/__init__.py", "zerver/filters.py", "zerver/middleware.py", "zerver/lib/bot_lib.py", diff --git a/version.py b/version.py index 4c37560b7d..4b6e13f6aa 100644 --- a/version.py +++ b/version.py @@ -45,4 +45,4 @@ API_FEATURE_LEVEL = 61 # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = "141.3" +PROVISION_VERSION = "142.0" diff --git a/zerver/__init__.py b/zerver/__init__.py index 08e90b7a2a..e69de29bb2 100644 --- a/zerver/__init__.py +++ b/zerver/__init__.py @@ -1,2 +0,0 @@ -# Load AppConfig app subclass by default on django applications initialization -default_app_config = "zerver.apps.ZerverConfig" diff --git a/zproject/computed_settings.py b/zproject/computed_settings.py index f4d881ad4f..d860911cb0 100644 --- a/zproject/computed_settings.py +++ b/zproject/computed_settings.py @@ -315,6 +315,8 @@ elif REMOTE_POSTGRES_HOST != "": POSTGRESQL_MISSING_DICTIONARIES = bool(get_config("postgresql", "missing_dictionaries", None)) +DEFAULT_AUTO_FIELD = "django.db.models.AutoField" + ######################################################################## # RABBITMQ CONFIGURATION ########################################################################