$customHeader
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The following are the changes introduced in Django 4.2 through 4.0 which seem most likely to impact Open edX developers once the upgrade from Django 3.2 to 4.2 is complete.  Many more minor changes can be found in the changelogs for Django 4.0,4.1, and4.2.  Some of these will be very useful for specific pieces of code, but probably aren’t of general interest to most Open edX developers; developers who can spare the time are encouraged to skim the changelogs at their convenience to see if there’s anything particularly useful for their work (or that they feel merits addition to the list of highlights below).

Impact Causing Changes

There are a few changes that need code refactoring in the edx-platform and other repos.

Changes in Django 4.0 Release

Django 4.0 has lots of Important changes which need significant work in openedx repos. Few of them are following 

  • The get_response argument for django.utils.deprecation.MiddlewareMixin.__init__() is required and doesn’t accept None. It will impact across all IDA’s and need code refactoring.

  • The providing_args argument for django.dispatch.Signal is removed. Again this change will require lots of changes. 

  • The NullBooleanField model field is removed, except for support in historical migrations.

  • The DEFAULT_HASHING_ALGORITHM transitional setting is removed.

  • Support for the pre-Django 3.1 encoding format of cookies values used by django.contrib.messages.storage.cookie.CookieStorage is removed.

  • The HttpRequest.is_ajax() method is removed.

Changes in Django 4.1 Release

Django 4.1 has lots of Important changes which need significant work in openedx repos. Few of them are following 

  • CsrfViewMiddleware no longer masks the CSRF cookie like it does the CSRF token in the DOM.

  • CsrfViewMiddleware now uses request.META['CSRF_COOKIE'] for storing the unmasked CSRF secret rather than a masked version. This is an undocumented, private API.

  • The exc_info argument of the undocumented django.utils.log.log_response() function is replaced by exception.

  • Support for assigning objects which don’t support creating deep copies with copy.deepcopy() to class attributes in TestCase.setUpTestData() is removed.

  • The whitelist argument and domain_whitelist attribute of django.core.validators.EmailValidator are removed.

  • The default_app_config application configuration variable is removed.

  • The django.core.cache.backends.memcached.MemcachedCache backend is removed.

  • Support for the pre-Django 3.2 format of messages used by django.contrib.messages.storage.cookie.CookieStorage is removed.

Changes in Django 4.2 Release

Django 4.2 has lots of Important changes which need significant work in openedx repos. Few of them are following 

  • Dropped-support-for-mysql-5-7: Upstream support for MySQL 5.7 ends in October 2023. Django 4.2 supports MySQL 8 and higher. Changelog

  • Setting update_fields in Model.save() may now be required. Changelog

  • ManifestStaticFilesStorage now replaces paths to CSS source map references with their hashed counterparts. See Django ticket for details. Basically if any js or css 3rd party package has map reference but does not contain map file it will break the collect static. 

These are some big changes apart from these there are lots of small changes as well.

Refactoring tools to upgrade codebase to Django 4.2

  • No labels