From faf439b617e84f5294d63f79cdc8c6242ef7772b Mon Sep 17 00:00:00 2001 From: Jean-Baptiste PENRATH Date: Fri, 19 Aug 2022 14:55:52 +0200 Subject: [PATCH] fix: add support of django 4.0 (#203) * fix: add support of django 4.0 django-cms 3.11 adds the support of django 4.0 but currently djangocms-link is not compatible with this version of django as there is use of force_text in the codebase. So we remove the use of this deprecated method in favor of `force_str`. Resolve #202 * Update tests/requirements/dj40_cms311.txt Co-authored-by: Mark Walker Co-authored-by: Vinit Kumar Co-authored-by: Mark Walker --- .github/workflows/test.yml | 1 + CHANGELOG.rst | 1 + djangocms_link/models.py | 6 +++--- tests/requirements/dj40_cms311.txt | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 tests/requirements/dj40_cms311.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1b4f6752..5a08bd7d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,7 @@ jobs: dj30_cms37.txt, dj30_cms38.txt, dj31_cms38.txt, + dj40_cms311.txt, ] os: [ ubuntu-20.04, diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 02be05cf..595705cf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,7 @@ Changelog Unreleased ========== +* Added support for Django 4.0 * Display page title instead of menu title diff --git a/djangocms_link/models.py b/djangocms_link/models.py index 2b8547b5..620a4331 100644 --- a/djangocms_link/models.py +++ b/djangocms_link/models.py @@ -6,7 +6,7 @@ from django.contrib.sites.models import Site from django.core.exceptions import ValidationError from django.db import models -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext from django.utils.translation import gettext_lazy as _ @@ -216,7 +216,7 @@ def clean(self): 'internal_link', ) - anchor_field_verbose_name = force_text( + anchor_field_verbose_name = force_str( self._meta.get_field(anchor_field_name).verbose_name) anchor_field_value = getattr(self, anchor_field_name) @@ -225,7 +225,7 @@ def clean(self): for key in field_names } link_field_verbose_names = { - key: force_text(self._meta.get_field(key).verbose_name) + key: force_str(self._meta.get_field(key).verbose_name) for key in link_fields.keys() } provided_link_fields = { diff --git a/tests/requirements/dj40_cms311.txt b/tests/requirements/dj40_cms311.txt new file mode 100644 index 00000000..cbd14b73 --- /dev/null +++ b/tests/requirements/dj40_cms311.txt @@ -0,0 +1,4 @@ +-r base.txt + +Django>=4.0,<4.1 +django-cms>=3.11,<4.0