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]: Upgrade Django to 4.2 #673

Merged
merged 3 commits into from
Oct 5, 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 @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
python-version: [py38]
django-version: [django32, django42]
django-version: [django42]

steps:
- uses: actions/checkout@v2
Expand All @@ -27,5 +27,5 @@ jobs:
run: |
docker exec -e TOXENV=${{ matrix.python-version }}-${{ matrix.django-version }} -u root enterprise.catalog.app /edx/app/enterprise_catalog/enterprise_catalog/validate.sh
- name: Code Coverage
if: matrix.python-version == 'py38' && matrix.django-version=='django32'
if: matrix.python-version == 'py38' && matrix.django-version=='django42'
uses: codecov/codecov-action@v1
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ TOX = ''
dev.up.build dev.down dev.destroy dev.stop docker_build \
shellcheck check_keywords install_transifex_client

COMMON_CONSTRAINTS_TXT=requirements/common_constraints.txt
.PHONY: $(COMMON_CONSTRAINTS_TXT)
$(COMMON_CONSTRAINTS_TXT):
wget -O "$(@)" https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt || touch "$(@)"

define BROWSER_PYSCRIPT
import os, webbrowser, sys
Expand Down Expand Up @@ -93,8 +97,10 @@ html_coverage: ## generate and view HTML coverage report
coverage html && open htmlcov/index.html

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: piptools ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
upgrade: $(COMMON_CONSTRAINTS_TXT) piptools ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
# Make sure to compile files after any other files they include!
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 --upgrade -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
Expand Down
4 changes: 4 additions & 0 deletions enterprise_catalog/apps/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class User(AbstractUser):
"""
full_name = models.CharField(_('Full Name'), max_length=255, blank=True, null=True)

# this avoids a migration which otherwise would come with Django 3.2 upgrade
# See, https://docs.djangoproject.com/en/3.2/releases/3.1/#abstractuser-first-name-max-length-increased-to-150
first_name = models.CharField(_('first name'), max_length=30, blank=True)

@property
def access_token(self):
"""
Expand Down
9 changes: 7 additions & 2 deletions enterprise_catalog/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('ENTERPRISE_CATALOG_SECRET_KEY', 'insecure-secret-key')

DEFAULT_HASHING_ALGORITHM = "sha1"

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

# SECURITY WARNING: don't run with debug turned on in production!
Expand Down Expand Up @@ -158,6 +156,11 @@

USE_TZ = True

# Django 4.0+ uses zoneinfo if this is not set. We can remove this and
# migrate to zoneinfo after Django 4.2 upgrade. See more on following url
# https://docs.djangoproject.com/en/4.2/releases/4.0/#zoneinfo-default-timezone-implementation
USE_DEPRECATED_PYTZ = True

LOCALE_PATHS = (
root('conf', 'locale'),
)
Expand Down Expand Up @@ -223,6 +226,7 @@

CSRF_COOKIE_SECURE = False
CSRF_TRUSTED_ORIGINS = []
CSRF_TRUSTED_ORIGINS_WITH_SCHEME = [] # just for Django 4.2 upgrade

# AUTHENTICATION CONFIGURATION
LOGIN_URL = '/login/'
Expand Down Expand Up @@ -436,3 +440,4 @@
#
# Enable this on stage first.
ENABLE_ENT_7729_ONLY_SHOW_COMPLETE_PROGRAMS = False

4 changes: 4 additions & 0 deletions enterprise_catalog/settings/production.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from os import environ
import django

Check warning on line 2 in enterprise_catalog/settings/production.py

View check run for this annotation

Codecov / codecov/patch

enterprise_catalog/settings/production.py#L2

Added line #L2 was not covered by tests
import yaml

from enterprise_catalog.settings.base import *
Expand Down Expand Up @@ -63,3 +64,6 @@

for override, value in DB_OVERRIDES.items():
DATABASES['default'][override] = value

if django.VERSION[0] >= 4: # for greater than django 3.2 use schemes.
CSRF_TRUSTED_ORIGINS = CSRF_TRUSTED_ORIGINS_WITH_SCHEME

Check warning on line 69 in enterprise_catalog/settings/production.py

View check run for this annotation

Codecov / codecov/patch

enterprise_catalog/settings/production.py#L69

Added line #L69 was not covered by tests
18 changes: 7 additions & 11 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ backoff==1.10.0
backports-zoneinfo[tzdata]==0.2.1
# via
# celery
# django
# kombu
billiard==4.1.0
# via celery
Expand Down Expand Up @@ -63,10 +64,8 @@ defusedxml==0.7.1
# djangorestframework-xml
# python3-openid
# social-auth-core
django==3.2.21
django==4.2.5
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/base.in
# django-celery-results
# django-clearcache
Expand Down Expand Up @@ -113,10 +112,8 @@ django-model-utils==4.3.1
# -r requirements/base.in
# edx-celeryutils
# edx-rbac
django-simple-history==3.0.0
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -r requirements/base.in
django-simple-history==3.4.0
# via -r requirements/base.in
django-waffle==4.0.0
# via
# edx-django-utils
Expand All @@ -135,7 +132,7 @@ djangorestframework-xml==2.0.0
# via -r requirements/base.in
drf-jwt==1.19.2
# via edx-drf-extensions
drf-spectacular==0.26.4
drf-spectacular==0.26.5
# via -r requirements/base.in
edx-auth-backends==4.2.0
# via -r requirements/base.in
Expand Down Expand Up @@ -187,7 +184,7 @@ monotonic==1.6
# via analytics-python
mysqlclient==2.2.0
# via -r requirements/base.in
newrelic==9.0.0
newrelic==9.1.0
# via edx-django-utils
oauthlib==3.2.2
# via
Expand Down Expand Up @@ -229,7 +226,6 @@ python3-openid==3.2.0
pytz==2023.3.post1
# via
# -r requirements/base.in
# django
# djangorestframework
pyyaml==6.0.1
# via
Expand Down Expand Up @@ -311,7 +307,7 @@ vine==5.0.0
# kombu
wcwidth==0.2.6
# via prompt-toolkit
xlsxwriter==3.1.4
xlsxwriter==3.1.5
# via -r requirements/base.in
zipp==3.17.0
# via
Expand Down
14 changes: 7 additions & 7 deletions requirements/common_constraints.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# 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-2721 for more details.
# Below is the copied and edited version of common_constraints

# A central location for most common version constraints
# (across edx repos) for pip-installation.
#
Expand All @@ -18,10 +13,15 @@


# 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
elasticsearch<7.14.0

setuptools<60
# django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected
django-simple-history==3.0.0

# tox>4.0.0 isn't yet compatible with many tox plugins, causing CI failures in almost all repos.
# Details can be found in this discussion: https://github.com/tox-dev/tox/discussions/1810
tox<4.0.0
3 changes: 1 addition & 2 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# pin when possible. Writing an issue against the offending project and
# linking to it here is good.

Django>=3.2,<4.0

# Common constraints for edx repos
-c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt

Expand All @@ -33,3 +31,4 @@ redis<4
edx-lint<5.3
pylint<2.15
astroid<2.12

18 changes: 7 additions & 11 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ backports-zoneinfo[tzdata]==0.2.1
# -r requirements/quality.txt
# -r requirements/test.txt
# celery
# django
# kombu
billiard==4.1.0
# via
Expand Down Expand Up @@ -152,10 +153,8 @@ distlib==0.3.7
# via
# -r requirements/test.txt
# virtualenv
django==3.2.21
django==4.2.5
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/quality.txt
# -r requirements/test.txt
# django-celery-results
Expand Down Expand Up @@ -223,9 +222,8 @@ django-model-utils==4.3.1
# -r requirements/test.txt
# edx-celeryutils
# edx-rbac
django-simple-history==3.0.0
django-simple-history==3.4.0
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -r requirements/quality.txt
# -r requirements/test.txt
django-waffle==4.0.0
Expand Down Expand Up @@ -256,7 +254,7 @@ drf-jwt==1.19.2
# -r requirements/quality.txt
# -r requirements/test.txt
# edx-drf-extensions
drf-spectacular==0.26.4
drf-spectacular==0.26.5
# via
# -r requirements/quality.txt
# -r requirements/test.txt
Expand Down Expand Up @@ -418,7 +416,7 @@ mysqlclient==2.2.0
# via
# -r requirements/quality.txt
# -r requirements/test.txt
newrelic==9.0.0
newrelic==9.1.0
# via
# -r requirements/quality.txt
# -r requirements/test.txt
Expand Down Expand Up @@ -579,7 +577,6 @@ pytz==2023.3.post1
# via
# -r requirements/quality.txt
# -r requirements/test.txt
# django
# djangorestframework
pyyaml==6.0.1
# via
Expand Down Expand Up @@ -710,12 +707,11 @@ tomlkit==0.12.1
# pylint
tox==3.28.0
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -r requirements/test.txt
# tox-battery
tox-battery==0.6.2
# via -r requirements/test.txt
types-pyyaml==6.0.12.11
types-pyyaml==6.0.12.12
# via
# -r requirements/test.txt
# responses
Expand Down Expand Up @@ -771,7 +767,7 @@ wrapt==1.15.0
# -r requirements/quality.txt
# -r requirements/test.txt
# astroid
xlsxwriter==3.1.4
xlsxwriter==3.1.5
# via
# -r requirements/quality.txt
# -r requirements/test.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/django.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
django==3.2.21
django==4.2.5
21 changes: 8 additions & 13 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ backports-zoneinfo[tzdata]==0.2.1
# via
# -r requirements/test.txt
# celery
# django
# kombu
beautifulsoup4==4.12.2
# via pydata-sphinx-theme
Expand Down Expand Up @@ -126,10 +127,8 @@ distlib==0.3.7
# via
# -r requirements/test.txt
# virtualenv
django==3.2.21
django==4.2.5
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/constraints.txt
# -r requirements/test.txt
# django-celery-results
# django-clearcache
Expand Down Expand Up @@ -178,10 +177,8 @@ django-model-utils==4.3.1
# -r requirements/test.txt
# edx-celeryutils
# edx-rbac
django-simple-history==3.0.0
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -r requirements/test.txt
django-simple-history==3.4.0
# via -r requirements/test.txt
django-waffle==4.0.0
# via
# -r requirements/test.txt
Expand Down Expand Up @@ -212,7 +209,7 @@ drf-jwt==1.19.2
# via
# -r requirements/test.txt
# edx-drf-extensions
drf-spectacular==0.26.4
drf-spectacular==0.26.5
# via -r requirements/test.txt
edx-auth-backends==4.2.0
# via -r requirements/test.txt
Expand Down Expand Up @@ -326,7 +323,7 @@ monotonic==1.6
# analytics-python
mysqlclient==2.2.0
# via -r requirements/test.txt
newrelic==9.0.0
newrelic==9.1.0
# via
# -r requirements/test.txt
# edx-django-utils
Expand Down Expand Up @@ -457,7 +454,6 @@ pytz==2023.3.post1
# via
# -r requirements/test.txt
# babel
# django
# djangorestframework
pyyaml==6.0.1
# via
Expand Down Expand Up @@ -585,12 +581,11 @@ tomlkit==0.12.1
# pylint
tox==3.28.0
# via
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -r requirements/test.txt
# tox-battery
tox-battery==0.6.2
# via -r requirements/test.txt
types-pyyaml==6.0.12.11
types-pyyaml==6.0.12.12
# via
# -r requirements/test.txt
# responses
Expand Down Expand Up @@ -636,7 +631,7 @@ wrapt==1.15.0
# via
# -r requirements/test.txt
# astroid
xlsxwriter==3.1.4
xlsxwriter==3.1.5
# via -r requirements/test.txt
zipp==3.17.0
# via
Expand Down
Loading
Loading