Skip to content

Commit e40a01c

Browse files
committed
feat!: upgrade Django version to 4.2 (LTS)
This reverts commit 23659d5.
1 parent a9bd61d commit e40a01c

File tree

13 files changed

+58
-41
lines changed

13 files changed

+58
-41
lines changed

.github/workflows/migrations-check.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@ jobs:
1616
os: [ ubuntu-20.04 ]
1717
python-version: [ 3.8 ]
1818
# 'pinned' is used to install the latest patch version of Django
19-
# within the global constraint i.e. Django==3.2.21 in current case
19+
# within the global constraint i.e. Django==4.2.8 in current case
2020
# because we have global constraint of Django<4.2
21-
django-version: ["pinned", "4.2"]
21+
django-version: ["pinned"]
2222
mongo-version: ["4"]
23-
mysql-version: ["5.7", "8"]
24-
# excluding mysql5.7 with Django 4.2 since Django 4.2 has
25-
# dropped support for MySQL<8
26-
exclude:
27-
- django-version: "4.2"
28-
mysql-version: "5.7"
23+
mysql-version: ["8"]
2924
services:
3025
mongo:
3126
image: mongo:${{ matrix.mongo-version }}

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
- "3.8"
1818
django-version:
1919
- "pinned"
20-
- "4.2"
2120
# When updating the shards, remember to make the same changes in
2221
# .github/workflows/unit-tests-gh-hosted.yml
2322
shard_name:

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ compile-requirements: pre-requirements $(COMMON_CONSTRAINTS_TXT) ## Re-compile *
157157
@# time someone tries to use the outputs.
158158
sed '/^django-simple-history==/d' requirements/common_constraints.txt > requirements/common_constraints.tmp
159159
mv requirements/common_constraints.tmp requirements/common_constraints.txt
160+
sed 's/Django<4.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp
161+
mv requirements/common_constraints.tmp requirements/common_constraints.txt
160162
pip-compile -v --allow-unsafe ${COMPILE_OPTS} -o requirements/pip.txt requirements/pip.in
161163
pip install -r requirements/pip.txt
162164

cms/envs/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,8 @@
11051105
}
11061106

11071107
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
1108-
# This will be overridden through CMS config
1109-
DEFAULT_HASHING_ALGORITHM = 'sha1'
1108+
DEFAULT_HASHING_ALGORITHM = 'sha256'
1109+
11101110
#################### Python sandbox ############################################
11111111

11121112
CODE_JAIL = {

lms/envs/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,8 +1768,8 @@ def _make_mako_template_dirs(settings):
17681768

17691769

17701770
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
1771-
# This will be overridden through LMS config
1772-
DEFAULT_HASHING_ALGORITHM = 'sha1'
1771+
DEFAULT_HASHING_ALGORITHM = 'sha256'
1772+
17731773
#################### Python sandbox ############################################
17741774

17751775
CODE_JAIL = {

openedx/core/djangoapps/safe_sessions/tests/test_safe_cookie_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def test_pinned_values(self):
236236
"|HvGnjXf1b3jU"
237237
"|ImExZWZiNzVlZGFmM2FkZWZmYjM4YjI0ZmZkOWU4MzExODU0MTk4NmVlNGRiYzBlODdhYWUzOGM5MzVlNzk4NjUi"
238238
":1m6Hve"
239-
":OMhY2FL2pudJjSSXChtI-zR8QVA"
239+
":Pra4iochviPvKUoIV33gdVZFDgG-cMDlIYfl8iFIMaY"
240240
)
241241

242242
@pytest.mark.skipif(django.VERSION[0] < 4, reason="For django42 default algorithm is sha256. No need for django32.")

openedx/core/djangoapps/theming/storage.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,33 +192,41 @@ def converter(matchobj):
192192
This requires figuring out which files the matched URL resolves
193193
to and calling the url() method of the storage.
194194
"""
195-
matched, url = matchobj.groups()
195+
matches = matchobj.groupdict()
196+
matched = matches["matched"]
197+
url = matches["url"]
196198

197199
# Ignore absolute/protocol-relative and data-uri URLs.
198-
if re.match(r'^[a-z]+:', url):
200+
if re.match(r"^[a-z]+:", url):
199201
return matched
200202

201203
# Ignore absolute URLs that don't point to a static file (dynamic
202204
# CSS / JS?). Note that STATIC_URL cannot be empty.
203-
if url.startswith('/') and not url.startswith(settings.STATIC_URL):
205+
if url.startswith("/") and not url.startswith(settings.STATIC_URL):
204206
return matched
205207

206208
# Strip off the fragment so a path-like fragment won't interfere.
207209
url_path, fragment = urldefrag(url)
208210

209-
if url_path.startswith('/'):
211+
# Ignore URLs without a path
212+
if not url_path:
213+
return matched
214+
215+
if url_path.startswith("/"):
210216
# Otherwise the condition above would have returned prematurely.
211217
assert url_path.startswith(settings.STATIC_URL)
212218
target_name = url_path[len(settings.STATIC_URL):]
213219
else:
214220
# We're using the posixpath module to mix paths and URLs conveniently.
215-
source_name = name if os.sep == '/' else name.replace(os.sep, '/')
221+
source_name = name if os.sep == "/" else name.replace(os.sep, "/")
216222
target_name = posixpath.join(posixpath.dirname(source_name), url_path)
217223

218224
# Determine the hashed name of the target file with the storage backend.
219225
hashed_url = self._url(
220-
self._stored_name, unquote(target_name),
221-
force=True, hashed_files=hashed_files,
226+
self._stored_name,
227+
unquote(target_name),
228+
force=True,
229+
hashed_files=hashed_files,
222230
)
223231

224232
# NOTE:
@@ -228,15 +236,19 @@ def converter(matchobj):
228236
# The line is commented and not removed to make future django upgrade easier and show exactly what is
229237
# changed in this method override
230238
#
231-
#transformed_url = '/'.join(url_path.split('/')[:-1] + hashed_url.split('/')[-1:])
239+
# transformed_url = "/".join(
240+
# url_path.split("/")[:-1] + hashed_url.split("/")[-1:]
241+
# )
242+
232243
transformed_url = hashed_url # This line was added.
233244

234245
# Restore the fragment that was stripped off earlier.
235246
if fragment:
236-
transformed_url += ('?#' if '?#' in url else '#') + fragment
247+
transformed_url += ("?#" if "?#" in url else "#") + fragment
237248

238249
# Return the hashed version to the file
239-
return template % unquote(transformed_url)
250+
matches["url"] = unquote(transformed_url)
251+
return template % matches
240252

241253
return converter
242254

requirements/common_constraints.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
# using LTS django version
20-
Django<4.0
20+
2121

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

requirements/constraints.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ click>=8.0,<9.0
2525
# for them.
2626
edx-enterprise==4.11.6
2727

28+
# Stay on LTS version, remove once this is added to common constraint
29+
Django<5.0
30+
2831
# django-oauth-toolkit version >=2.0.0 has breaking changes. More details
2932
# mentioned on this issue https://github.com/openedx/edx-platform/issues/32884
3033
django-oauth-toolkit==1.7.1
3134

35+
# incremental upgrade
36+
django-simple-history==3.4.0
3237

3338
# constrained in opaque_keys. migration guide here: https://pymongo.readthedocs.io/en/4.0/migrate-to-pymongo4.html
3439
# Major upgrade will be done in separate ticket.

requirements/edx/base.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ backoff==1.10.0
5656
backports-zoneinfo[tzdata]==0.2.1
5757
# via
5858
# celery
59+
# django
5960
# icalendar
6061
# kombu
6162
beautifulsoup4==4.12.3
@@ -173,9 +174,9 @@ defusedxml==0.7.1
173174
# social-auth-core
174175
deprecated==1.2.14
175176
# via jwcrypto
176-
django==3.2.23
177+
django==4.2.9
177178
# via
178-
# -c requirements/edx/../common_constraints.txt
179+
# -c requirements/edx/../constraints.txt
179180
# -r requirements/edx/kernel.in
180181
# django-appconf
181182
# django-celery-results
@@ -338,6 +339,7 @@ django-ses==3.5.2
338339
# via -r requirements/edx/bundled.in
339340
django-simple-history==3.4.0
340341
# via
342+
# -c requirements/edx/../constraints.txt
341343
# -r requirements/edx/kernel.in
342344
# edx-enterprise
343345
# edx-name-affirmation
@@ -431,7 +433,7 @@ edx-ccx-keys==1.2.1
431433
# via
432434
# -r requirements/edx/kernel.in
433435
# lti-consumer-xblock
434-
edx-celeryutils==1.2.3
436+
edx-celeryutils==1.2.5
435437
# via
436438
# -r requirements/edx/kernel.in
437439
# edx-name-affirmation
@@ -940,7 +942,6 @@ pytz==2023.4
940942
# via
941943
# -r requirements/edx/kernel.in
942944
# babel
943-
# django
944945
# django-ses
945946
# djangorestframework
946947
# drf-yasg

0 commit comments

Comments
 (0)