Skip to content

Commit

Permalink
Upgraded Django support (from 4.2 to 5.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Aug 1, 2024
1 parent 0027b69 commit 6bba67d
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ example/settings_private.py
/.tox/
/htmlcov/
/docs/_build/
/dist/
.eggs/

.idea/
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
### Changed
- Allow django-phonenumber-field 8.x.x.

### Added
- Support confirmation for Django 5.1.

### Removed
- Dropped support for Django <4.2.

## 1.16.0
### Fixed
- Avoid potentially empty `<ul>` on the profile page.
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ providing Django sessions with a foreign key to the user. Although the package
is optional, it improves account security control over
``django.contrib.sessions``.

Compatible with supported Django and Python versions. At the moment of writing that
includes 3.2, 4.0, 4.1, and 4.2 on Python 3.8, 3.9, 3.10 and 3.11.
Compatible with supported Django and Python versions. At the moment of writing
that includes 4.2, 5.0, and 5.1 on Python 3.8 to 3.12.
Documentation is available at `readthedocs.io`_.


Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Requirements

Django
------
Supported Django versions are supported. Currently this list includes Django 3.2, 4.0,
4.1, 4.2 and 5.0.
Supported Django versions are supported. Currently this list includes Django 4.2,
5.0 and 5.1.

Python
------
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ maintainers = [
license = {text = "MIT"}
requires-python = ">= 3.8"
dependencies = [
"Django>=3.2",
"Django>=4.2",
"django_otp>=0.8.0",
"qrcode>=4.0.0,<7.99",
"django-phonenumber-field<9",
Expand All @@ -28,11 +28,9 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
Expand Down
13 changes: 4 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[tox]
envlist =
py{38,39,310}-dj32-{normal,yubikey,custom_user,webauthn}
py{38,39,310,311}-dj{40,41,42}-{normal,yubikey,custom_user,webauthn}
py{310,311,312}-dj{50,main}-{normal,yubikey,custom_user,webauthn}
py{38,39,310,311,312}-dj42-{normal,yubikey,custom_user,webauthn}
py{310,311,312}-dj{50,51,main}-{normal,yubikey,custom_user,webauthn}

[gh-actions]
python =
Expand All @@ -14,11 +13,9 @@ python =

[gh-actions:env]
DJANGO =
3.2: dj32
4.0: dj40
4.1: dj41
4.2: dj42
5.0: dj50
5.1: dj51
main: djmain
VARIANT =
normal: normal
Expand All @@ -41,11 +38,9 @@ basepython =
py311: python3.11
py312: python3.12
deps =
dj32: Django<4.0
dj40: Django<4.1
dj41: Django<4.2
dj42: Django<5.0
dj50: Django<5.1
dj51: Django<5.2
djmain: https://github.com/django/django/archive/main.tar.gz
webauthn: -rrequirements_e2e.txt
extras =
Expand Down
3 changes: 0 additions & 3 deletions two_factor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
import django

if django.VERSION <= (3, 2):
default_app_config = 'two_factor.apps.TwoFactorConfig'
3 changes: 0 additions & 3 deletions two_factor/plugins/yubikey/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
import django

if django.VERSION <= (3, 2):
default_app_config = 'two_factor.plugins.yubikey.apps.TwoFactorYubikeyConfig'
7 changes: 1 addition & 6 deletions two_factor/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from django.contrib.auth import REDIRECT_FIELD_NAME, login
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.views import RedirectURLMixin
from django.contrib.sites.shortcuts import get_current_site
from django.core.signing import BadSignature
from django.forms import Form, ValidationError
Expand Down Expand Up @@ -50,12 +51,6 @@
get_remember_device_cookie, validate_remember_device_cookie,
)

try:
from django.contrib.auth.views import RedirectURLMixin
except ImportError: # django<4.1
from django.contrib.auth.views import (
SuccessURLAllowedHostsMixin as RedirectURLMixin,
)
logger = logging.getLogger(__name__)

REMEMBER_COOKIE_PREFIX = getattr(settings, 'TWO_FACTOR_REMEMBER_COOKIE_PREFIX', 'remember-cookie_')
Expand Down
12 changes: 3 additions & 9 deletions two_factor/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
from django.conf import settings
from django.contrib.auth import load_backend
from django.core.exceptions import SuspiciousOperation
from django.core.signing import BadSignature, SignatureExpired
from django.core.signing import (
BadSignature, SignatureExpired, b62_decode, b62_encode,
)
from django.utils.crypto import salted_hmac
from django.utils.decorators import method_decorator
from django.utils.encoding import force_bytes
Expand All @@ -14,14 +16,6 @@
from formtools.wizard.storage.session import SessionStorage
from formtools.wizard.views import SessionWizardView

try:
from django.core.signing import b62_decode, b62_encode
except ImportError: # Django < 4.0
# Deprecated in Django 4.0, removed in Django 5.0
from django.utils import baseconv
b62_decode = baseconv.base62.decode
b62_encode = baseconv.base62.encode

logger = logging.getLogger(__name__)


Expand Down

0 comments on commit 6bba67d

Please sign in to comment.