From 6e5f75b244f742d75bbfceb8dd99f9c933aaf0d5 Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Tue, 12 Dec 2023 13:57:38 -0400 Subject: [PATCH 1/2] fix: wrap django 4 imports in try-except block --- ...40233_maria.grimaldi_fix_django4_import_errors.md | 12 ++++++++++++ .../apps/openedx/settings/partials/common_all.py | 9 ++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 changelog.d/20231212_140233_maria.grimaldi_fix_django4_import_errors.md diff --git a/changelog.d/20231212_140233_maria.grimaldi_fix_django4_import_errors.md b/changelog.d/20231212_140233_maria.grimaldi_fix_django4_import_errors.md new file mode 100644 index 0000000..f677a60 --- /dev/null +++ b/changelog.d/20231212_140233_maria.grimaldi_fix_django4_import_errors.md @@ -0,0 +1,12 @@ + + + + +[Bugfix] Wrap Django5 warning imports in try-except block to avoid failures in django3 that's still in use in edx-platform's master branch. diff --git a/tutor/templates/apps/openedx/settings/partials/common_all.py b/tutor/templates/apps/openedx/settings/partials/common_all.py index c088b97..ec68e3e 100644 --- a/tutor/templates/apps/openedx/settings/partials/common_all.py +++ b/tutor/templates/apps/openedx/settings/partials/common_all.py @@ -150,9 +150,12 @@ LOGGING["loggers"]["blockstore.apps.bundles.storage"] = {"handlers": ["console"] # These warnings are visible in simple commands and init tasks import warnings -from django.utils.deprecation import RemovedInDjango50Warning, RemovedInDjango51Warning -warnings.filterwarnings("ignore", category=RemovedInDjango50Warning) -warnings.filterwarnings("ignore", category=RemovedInDjango51Warning) +try: + from django.utils.deprecation import RemovedInDjango50Warning, RemovedInDjango51Warning + warnings.filterwarnings("ignore", category=RemovedInDjango50Warning) + warnings.filterwarnings("ignore", category=RemovedInDjango51Warning) +except ImportError: + pass warnings.filterwarnings("ignore", category=DeprecationWarning, module="wiki.plugins.links.wiki_plugin") warnings.filterwarnings("ignore", category=DeprecationWarning, module="boto.plugin") From 64d82c38c88085d7e5e03e06344ca474b9e64bdf Mon Sep 17 00:00:00 2001 From: "Kyle D. McCormick" Date: Mon, 18 Dec 2023 16:50:01 -0500 Subject: [PATCH 2/2] docs: add REMOVE-AFTER-V18 comment to Django 5 import try-except also fixup changelog format --- ...0233_maria.grimaldi_fix_django4_import_errors.md | 13 +------------ .../apps/openedx/settings/partials/common_all.py | 4 ++++ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/changelog.d/20231212_140233_maria.grimaldi_fix_django4_import_errors.md b/changelog.d/20231212_140233_maria.grimaldi_fix_django4_import_errors.md index f677a60..ad88d1c 100644 --- a/changelog.d/20231212_140233_maria.grimaldi_fix_django4_import_errors.md +++ b/changelog.d/20231212_140233_maria.grimaldi_fix_django4_import_errors.md @@ -1,12 +1 @@ - - - - -[Bugfix] Wrap Django5 warning imports in try-except block to avoid failures in django3 that's still in use in edx-platform's master branch. +- [Bugfix] Wrap Django5 warning imports in try-except block to avoid failures in django3 that's still in use in edx-platform's master branch (by @mariajgrimaldi). diff --git a/tutor/templates/apps/openedx/settings/partials/common_all.py b/tutor/templates/apps/openedx/settings/partials/common_all.py index ec68e3e..cf3bc44 100644 --- a/tutor/templates/apps/openedx/settings/partials/common_all.py +++ b/tutor/templates/apps/openedx/settings/partials/common_all.py @@ -155,6 +155,10 @@ try: warnings.filterwarnings("ignore", category=RemovedInDjango50Warning) warnings.filterwarnings("ignore", category=RemovedInDjango51Warning) except ImportError: + # REMOVE-AFTER-V18: + # In Quince, edx-platform uses Django 5. But on master, edx-platform still uses Django 3. + # So, Tutor v17 needs to silence these warnings, whereas Tutor v17-nightly fails to import them. + # Once edx-platform master is upgraded to Django 5, the try-except wrapper can be removed. pass warnings.filterwarnings("ignore", category=DeprecationWarning, module="wiki.plugins.links.wiki_plugin")