summaryrefslogtreecommitdiff
path: root/semantic_version/django_fields.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@paylead.fr>2021-11-08 14:18:29 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2021-11-08 14:56:48 +0100
commit8abf0030e215804eb84e63a9233010abc02e05a5 (patch)
treee95b065da1c8cdbe7a91f01f3de95e74afc1f1b8 /semantic_version/django_fields.py
parent63720c70dd538234e75914e2afb80b94d5e88a1f (diff)
downloadsemantic-version-8abf0030e215804eb84e63a9233010abc02e05a5.tar.gz
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
Diffstat (limited to 'semantic_version/django_fields.py')
-rw-r--r--semantic_version/django_fields.py8
1 files changed, 7 insertions, 1 deletions
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