Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Django 4.2]: Django 4.2 Upgrade #2196

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
strategy:
matrix:
python-version: ["py38"]
django-version: ["django32", "django42"]
django-version: ["django42"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
strategy:
matrix:
python-version: ["py38"]
django-version: ["django32"]
django-version: ["django42"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ $(COMMON_CONSTRAINTS_TXT):

export CUSTOM_COMPILE_COMMAND = make upgrade
upgrade: piptools $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
# This is a temporary solution to override the real common_constraints.txt
# In edx-lint, until the pyjwt constraint in edx-lint has been removed.
# See BOM-271 for more details.
sed '/^django-simple-history==/d' requirements/common_constraints.txt > requirements/common_constraints.tmp
mv requirements/common_constraints.tmp requirements/common_constraints.txt
sed 's/Django<4.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp
mv requirements/common_constraints.tmp requirements/common_constraints.txt
pip-compile --allow-unsafe --rebuild --upgrade -o requirements/pip.txt requirements/pip.in
pip-compile --rebuild --upgrade -o requirements/pip_tools.txt requirements/pip_tools.in
pip install -qr requirements/pip.txt
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.5 on 2023-09-20 08:27

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("credentials", "0026_alter_historicalprogramcompletionemailconfiguration_options"),
]

operations = [
migrations.AlterModelOptions(
name="historicalprogramcompletionemailconfiguration",
options={
"get_latest_by": "history_date",
"ordering": ("-history_date", "-history_id"),
"verbose_name": "historical program completion email configuration",
},
),
]
4 changes: 2 additions & 2 deletions credentials/apps/records/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ def get(self, request, *args, **kwargs):
context = {
"page": {
"path": request.path,
"referrer": request.META.get("HTTP_REFERER"),
"referrer": request.headers.get("referer"),
"url": request.build_absolute_uri(),
},
"userAgent": request.META.get("HTTP_USER_AGENT"),
"userAgent": request.headers.get("user-agent"),
}

# Use the value of 'ajs_anonymous_id' as the anonymous id if the cookie exists, otherwise generate a UUID to
Expand Down
5 changes: 3 additions & 2 deletions credentials/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@
TIME_ZONE = "UTC"
TIME_ZONE_CLASS = timezone.utc

# https://docs.djangoproject.com/en/4.2/releases/4.0/#zoneinfo-default-timezone-implementation
USE_DEPRECATED_PYTZ = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Django switched from the pytz third-party python package to the Python native package zoneinfo in Django 4.0. In release notes, they have mentioned that both are not equivalent so one might need some manual work for this migration. So Django provided this USE_DEPRECATED_PYTZ setting, so we can decouple this migration from the Django upgrade.

More info: https://docs.djangoproject.com/en/4.2/releases/4.0/#zoneinfo-default-timezone-implementation


USE_I18N = True

USE_L10N = True
Expand All @@ -234,8 +237,6 @@

LOCALE_PATHS = (root("conf", "locale"),)

DEFAULT_HASHING_ALGORITHM = "sha1"
Copy link
Contributor

@awais786 awais786 Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Django4.2 has dropped sha1 support. For details https://github.com/orgs/edx/projects/12/views/8?pane=issue&itemId=39005351

Its side effect it might logout the users from credentials.


DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

# MEDIA CONFIGURATION
Expand Down
4 changes: 2 additions & 2 deletions credentials/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
path("health/", core_views.health, name="health"),
path("management/", include(("credentials.apps.edx_django_extensions.urls", "management"), namespace="management")),
path("records/", include(("credentials.apps.records.urls", "records"), namespace="records")),
path("program-listing/", ProgramListingView.as_view(), name="program_listing"),
path("favicon.ico", FaviconView.as_view(permanent=True)),
re_path(r"^program-listing/", ProgramListingView.as_view(), name="program_listing"),
re_path(r"^favicon\.ico$", FaviconView.as_view(permanent=True)),
path("mock-toggles", MockToggleStateView.as_view()),
]

Expand Down
48 changes: 26 additions & 22 deletions requirements/all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ backoff==1.10.0
# -r requirements/dev.txt
# -r requirements/production.txt
# analytics-python
backports-zoneinfo==0.2.1
# via
# -r requirements/dev.txt
# -r requirements/production.txt
# django
bcrypt==4.0.1
# via
# -r requirements/dev.txt
Expand All @@ -41,11 +46,11 @@ bleach==6.0.0
# via
# -r requirements/dev.txt
# -r requirements/production.txt
boto3==1.28.57
boto3==1.28.61
# via
# -r requirements/production.txt
# django-ses
botocore==1.31.57
botocore==1.31.61
# via
# -r requirements/production.txt
# boto3
Expand All @@ -61,7 +66,7 @@ cffi==1.16.0
# -r requirements/production.txt
# cryptography
# pynacl
charset-normalizer==3.2.0
charset-normalizer==3.3.0
# via
# -r requirements/dev.txt
# -r requirements/production.txt
Expand Down Expand Up @@ -96,7 +101,7 @@ coreschema==0.0.4
# -r requirements/dev.txt
# -r requirements/production.txt
# coreapi
coverage==7.3.1
coverage==7.3.2
# via -r requirements/dev.txt
cryptography==41.0.4
# via
Expand All @@ -107,7 +112,7 @@ cryptography==41.0.4
# social-auth-core
ddt==1.6.0
# via -r requirements/dev.txt
defusedxml==0.8.0rc1
defusedxml==0.8.0rc2
# via
# -r requirements/dev.txt
# -r requirements/production.txt
Expand All @@ -129,10 +134,8 @@ distro==1.8.0
# via
# -r requirements/dev.txt
# docker-compose
django==3.2.21
django==4.2.6
# via
# -c requirements/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/dev.txt
# -r requirements/production.txt
# django-appconf
Expand Down Expand Up @@ -209,7 +212,7 @@ django-statici18n==2.4.0
# via
# -r requirements/dev.txt
# -r requirements/production.txt
django-storages==1.14
django-storages==1.14.1
# via
# -r requirements/dev.txt
# -r requirements/production.txt
Expand Down Expand Up @@ -293,7 +296,6 @@ edx-event-bus-kafka==5.5.0
# -r requirements/production.txt
edx-i18n-tools==1.3.0
# via
# -c requirements/constraints.txt
# -r requirements/dev.txt
# -r requirements/production.txt
# edx-credentials-themes
Expand Down Expand Up @@ -324,7 +326,7 @@ faker==19.6.2
# via
# -r requirements/dev.txt
# factory-boy
fastavro==1.8.3
fastavro==1.8.4
# via
# -r requirements/dev.txt
# -r requirements/production.txt
Expand All @@ -336,7 +338,7 @@ filelock==3.12.4
# virtualenv
gevent==23.9.1
# via -r requirements/production.txt
greenlet==2.0.2
greenlet==3.0.0
# via
# -r requirements/production.txt
# gevent
Expand Down Expand Up @@ -391,6 +393,11 @@ lazy-object-proxy==1.9.0
# via
# -r requirements/dev.txt
# astroid
lxml==4.9.3
# via
# -r requirements/dev.txt
# -r requirements/production.txt
# edx-i18n-tools
markdown==3.4.4
# via
# -r requirements/dev.txt
Expand Down Expand Up @@ -439,12 +446,12 @@ openedx-atlas==0.5.0
# via
# -r requirements/dev.txt
# -r requirements/production.txt
openedx-events==8.6.0
openedx-events==8.9.0
# via
# -r requirements/dev.txt
# -r requirements/production.txt
# edx-event-bus-kafka
packaging==23.1
packaging==23.2
# via
# -r requirements/dev.txt
# -r requirements/production.txt
Expand Down Expand Up @@ -476,7 +483,7 @@ pillow==10.0.1
# via
# -r requirements/dev.txt
# -r requirements/production.txt
platformdirs==3.10.0
platformdirs==3.11.0
# via
# -r requirements/dev.txt
# black
Expand Down Expand Up @@ -519,7 +526,7 @@ pyjwt[crypto]==2.8.0
# edx-drf-extensions
# edx-rest-api-client
# social-auth-core
pylint==2.17.6
pylint==2.17.7
# via
# -r requirements/dev.txt
# edx-lint
Expand Down Expand Up @@ -599,12 +606,9 @@ pytz==2023.3.post1
# via
# -r requirements/dev.txt
# -r requirements/production.txt
# django
# django-ses
# djangorestframework
# drf-yasg
pywatchman==1.4.1 ; "linux" in sys_platform
# via -r requirements/dev.txt
pyyaml==5.4.1
# via
# -c requirements/constraints.txt
Expand Down Expand Up @@ -716,7 +720,7 @@ text-unidecode==1.3
# -r requirements/dev.txt
# -r requirements/production.txt
# python-slugify
texttable==1.6.7
texttable==1.7.0
# via
# -r requirements/dev.txt
# docker-compose
Expand Down Expand Up @@ -756,7 +760,7 @@ uritemplate==4.1.1
# -r requirements/production.txt
# coreapi
# drf-yasg
urllib3==1.26.16
urllib3==1.26.17
# via
# -c requirements/constraints.txt
# -r requirements/dev.txt
Expand Down Expand Up @@ -796,7 +800,7 @@ zope-event==5.0
# via
# -r requirements/production.txt
# gevent
zope-interface==6.0
zope-interface==6.1
# via
# -r requirements/production.txt
# gevent
Expand Down
27 changes: 13 additions & 14 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ attrs==23.1.0
# openedx-events
backoff==1.10.0
# via analytics-python
backports-zoneinfo==0.2.1
# via django
bleach==6.0.0
# via -r requirements/base.in
certifi==2023.7.22
Expand All @@ -24,7 +26,7 @@ cffi==1.16.0
# via
# cryptography
# pynacl
charset-normalizer==3.2.0
charset-normalizer==3.3.0
# via requests
click==8.1.7
# via
Expand All @@ -43,16 +45,14 @@ cryptography==41.0.4
# via
# pyjwt
# social-auth-core
defusedxml==0.8.0rc1
defusedxml==0.8.0rc2
# via
# python3-openid
# social-auth-core
didkit==0.3.2
# via -r requirements/base.in
django==3.2.21
django==4.2.6
# via
# -c requirements/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/base.in
# django-appconf
# django-cors-headers
Expand Down Expand Up @@ -102,7 +102,7 @@ django-sortedm2m==3.1.1
# via -r requirements/base.in
django-statici18n==2.4.0
# via -r requirements/base.in
django-storages==1.14
django-storages==1.14.1
# via -r requirements/base.in
django-waffle==4.0.0
# via
Expand Down Expand Up @@ -145,9 +145,7 @@ edx-drf-extensions==8.10.0
edx-event-bus-kafka==5.5.0
# via -r requirements/base.in
edx-i18n-tools==1.3.0
# via
# -c requirements/constraints.txt
# edx-credentials-themes
# via edx-credentials-themes
edx-opaque-keys[django]==2.5.1
# via
# -r requirements/base.in
Expand All @@ -159,7 +157,7 @@ edx-toggles==5.1.0
# via
# -r requirements/base.in
# edx-event-bus-kafka
fastavro==1.8.3
fastavro==1.8.4
# via openedx-events
idna==3.4
# via requests
Expand All @@ -173,6 +171,8 @@ jinja2==3.1.2
# via
# code-annotations
# coreschema
lxml==4.9.3
# via edx-i18n-tools
markdown==3.4.4
# via -r requirements/base.in
markupsafe==2.1.3
Expand All @@ -193,9 +193,9 @@ openapi-codec==1.3.2
# via django-rest-swagger
openedx-atlas==0.5.0
# via -r requirements/base.in
openedx-events==8.6.0
openedx-events==8.9.0
# via edx-event-bus-kafka
packaging==23.1
packaging==23.2
# via drf-yasg
path==16.7.1
# via edx-i18n-tools
Expand Down Expand Up @@ -239,7 +239,6 @@ python3-openid==3.2.0
pytz==2023.3.post1
# via
# -r requirements/base.in
# django
# djangorestframework
# drf-yasg
pyyaml==5.4.1
Expand Down Expand Up @@ -311,7 +310,7 @@ uritemplate==4.1.1
# via
# coreapi
# drf-yasg
urllib3==1.26.16
urllib3==1.26.17
# via
# -c requirements/constraints.txt
# requests
Expand Down
2 changes: 1 addition & 1 deletion requirements/common_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


# using LTS django version
Django<4.0


# elasticsearch>=7.14.0 includes breaking changes in it which caused issues in discovery upgrade process.
# elastic search changelog: https://www.elastic.co/guide/en/enterprise-search/master/release-notes-7.14.0.html
Expand Down
Loading
Loading