From 8abf0030e215804eb84e63a9233010abc02e05a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Mon, 8 Nov 2021 14:18:29 +0100 Subject: Add support for Django 4.0 The gettext_lazy function has a different name between Django 2.x and 4.x; use the right one according to the version. Closes #113, #121 --- .github/workflows/test.yml | 8 ++++++++ ChangeLog | 4 ++-- semantic_version/django_fields.py | 8 +++++++- tox.ini | 2 ++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7eb4638..02cb641 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,6 +45,14 @@ jobs: - python-version: "pypy3" django-family: 32 + # Django 4.0: Python 3.8, 3.9, 3.10 + - python-version: "3.8" + django-family: 40 + - python-version: "3.9" + django-family: 40 + - python-version: "3.10" + django-family: 40 + env: TOXENV: django${{ matrix.django-family }} diff --git a/ChangeLog b/ChangeLog index c8453e5..211be6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,8 +6,8 @@ ChangeLog *New:* - * Add support for Django 3.1 - * Add support for Python 3.7 / 3.8 / 3.9 + * Add support for Django 3.1, 3.2, 4.0 + * Add support for Python 3.7 / 3.8 / 3.9 / 3.10 2.8.5 (2020-04-29) diff --git a/semantic_version/django_fields.py b/semantic_version/django_fields.py index caa7a8c..e5bd7eb 100644 --- a/semantic_version/django_fields.py +++ b/semantic_version/django_fields.py @@ -4,8 +4,14 @@ import warnings +import django from django.db import models -from django.utils.translation import ugettext_lazy as _ + +if django.VERSION >= (3, 0): + # See https://docs.djangoproject.com/en/dev/releases/3.0/#features-deprecated-in-3-0 + from django.utils.translation import gettext_lazy as _ +else: + from django.utils.translation import ugettext_lazy as _ from . import base diff --git a/tox.ini b/tox.ini index 31e6e34..26cbebe 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,7 @@ envlist = py{27,34,35,36,37}-django111 py{35,36,37,38}-django22 py{36,37,38,39,310}-django32 + py{38,39,310}-django40 pypy3-django{111,22,32} lint @@ -14,6 +15,7 @@ deps = django111: Django>=1.11,<1.12 django22: Django>=2.2,<2.3 django32: Django>=3.2,<3.3 + django40: Django>=4.0a1,<4.1 whitelist_externals = make commands = make test -- cgit v1.2.1