From 17205549eb667d8b993eb485e468a36100d96026 Mon Sep 17 00:00:00 2001 From: Stan Triepels <1939656+GDay@users.noreply.github.com> Date: Wed, 9 Nov 2022 00:41:12 +0100 Subject: [PATCH] Fix baseconv/base62 deprecation warning for Django 5.x (#34) --- CHANGELOG.md | 3 ++- django_q/core_signing.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 204b686..ec11595 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased](https://github.com/GDay/django-q2/tree/HEAD) +**Merged pull requests:** +- Fix: Deprecation warning for Django 5.x ## [v1.4.3](https://github.com/GDay/django-q2/tree/v1.4.3) (2022-11-07) @@ -10,7 +12,6 @@ - Fix: func reference in admin https://github.com/GDay/django-q2/pull/28 - Add python 3.11 support and remove 3.7 (as it was never supported by this package anyway) - ## [v1.4.2](https://github.com/GDay/django-q2/tree/v1.4.2) (2022-10-22) **Merged pull requests:** diff --git a/django_q/core_signing.py b/django_q/core_signing.py index 03e83a4..6d2d899 100644 --- a/django_q/core_signing.py +++ b/django_q/core_signing.py @@ -6,7 +6,11 @@ from django.core.signing import BadSignature, JSONSerializer, SignatureExpired from django.core.signing import Signer as Sgnr from django.core.signing import TimestampSigner as TsS from django.core.signing import b64_decode, dumps -from django.utils import baseconv +try: + from django.core.signing import base62 +except ImportError: + # For django < 4.0 + from django.utils.baseconv import base62 from django.utils.crypto import constant_time_compare from django.utils.encoding import force_bytes, force_str @@ -69,7 +73,7 @@ class TimestampSigner(Signer, TsS): """ result = super(TimestampSigner, self).unsign(value) value, timestamp = result.rsplit(self.sep, 1) - timestamp = baseconv.base62.decode(timestamp) + timestamp = base62.decode(timestamp) if max_age is not None: if isinstance(max_age, datetime.timedelta): max_age = max_age.total_seconds()