From 2191ec336840570df7b17a33e95d69e232cc5a50 Mon Sep 17 00:00:00 2001 From: Olivier Dalang Date: Wed, 18 Jun 2025 15:17:55 +0200 Subject: [PATCH 1/5] test against django5.2 --- .github/workflows/test.yml | 2 +- tox.ini | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d9119ba..e7f17e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 diff --git a/tox.ini b/tox.ini index 93d4ac5..53aad25 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ ignore = W503, E203 # See https://github.com/PyCQA/pycodestyle/issues/373 max-line-length=160 [tox] -envlist = py{38,39,310,311,312}-django{32,40},py{310,311,312}-django{50} +envlist = py{38,39,310,311,312}-django{42},py{310,311,312,313}-django{51,52} recreate = True [gh-actions] @@ -14,6 +14,7 @@ python = 3.10: py310 3.11: py311 3.12: py312 + 3.13: py313 [testenv] basepython = @@ -22,12 +23,10 @@ basepython = py310: python3.10 py311: python3.11 py312: python3.12 + py313: python3.13 deps = -r{toxinidir}/pip-requirements-test.txt - django22: Django>=2.2,<2.3 - django30: Django>=3.0,<3.1 - django31: Django>=3.1,<3.2 - django32: Django>=3.2,<3.3 - django40: Django>=4.0,<5.0 - django50: Django>=5.0,<6.0 + django42: Django==4.2.* + django51: Django==5.1.* + django52: Django==5.2.* commands = django-admin test --traceback --pythonpath=. --settings=binary_database_files.tests.settings binary_database_files.tests.tests.DatabaseFilesTestCase{env:TESTNAME:} From 2b95658c8db41fbb0c4ec2868543ffa415e3e367 Mon Sep 17 00:00:00 2001 From: Olivier Dalang Date: Wed, 18 Jun 2025 15:23:21 +0200 Subject: [PATCH 2/5] (still test 5.0) --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 53aad25..d0d558a 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ ignore = W503, E203 # See https://github.com/PyCQA/pycodestyle/issues/373 max-line-length=160 [tox] -envlist = py{38,39,310,311,312}-django{42},py{310,311,312,313}-django{51,52} +envlist = py{38,39,310,311,312}-django{42},py{310,311,312}-django{50},py{310,311,312,313}-django{51,52} recreate = True [gh-actions] @@ -27,6 +27,7 @@ basepython = deps = -r{toxinidir}/pip-requirements-test.txt django42: Django==4.2.* + django50: Django==5.0.* django51: Django==5.1.* django52: Django==5.2.* commands = django-admin test --traceback --pythonpath=. --settings=binary_database_files.tests.settings binary_database_files.tests.tests.DatabaseFilesTestCase{env:TESTNAME:} From f7e74cb35da4314e7c353c9e126f3ae816133ceb Mon Sep 17 00:00:00 2001 From: Olivier Dalang Date: Wed, 18 Jun 2025 15:25:39 +0200 Subject: [PATCH 3/5] ci: no failfast --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e7f17e6..28d220d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,7 @@ jobs: build: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] From 1ea6e234655e48e9d6dfa30e27b26ce3d3edb626 Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Wed, 18 Jun 2025 15:57:52 +0200 Subject: [PATCH 4/5] DEFAULT_FILE_STORAGE was deprecated in django 4.2 in favor or STORAGES --- README.md | 8 ++++++-- binary_database_files/tests/tests.py | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5cf9acd..43e2c87 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,13 @@ Usage ----- In `settings.py`, add `binary_database_files` to your `INSTALLED_APPS` and add -this line: +this: - DEFAULT_FILE_STORAGE = 'binary_database_files.storage.DatabaseStorage' + STORAGES = { + "default": { + "BACKEND": "binary_database_files.storage.DatabaseStorage" + } + } Note, the `upload_to` parameter is still used to synchronize the files stored in the database with those on the file system, so new and existing fields diff --git a/binary_database_files/tests/tests.py b/binary_database_files/tests/tests.py index 5854175..04fdd37 100644 --- a/binary_database_files/tests/tests.py +++ b/binary_database_files/tests/tests.py @@ -6,6 +6,7 @@ from io import BytesIO from zipfile import ZipFile +import django from django.conf import settings from django.core import files from django.core.files import File as DjangoFile @@ -23,10 +24,20 @@ DIR = os.path.abspath(os.path.split(__file__)[0]) -set_default_file_storage = functools.partial( - override_settings, - DEFAULT_FILE_STORAGE="binary_database_files.storage.DatabaseStorage", -) +if django.VERSION <= (4, 2): + # DEFAULT_FILE_STORAGE was deprecated in 4.2 (https://https://docs.djangoproject.com/en/dev/releases/4.2/#id1) + # remove this when 4.2 is not supported anymore + set_default_file_storage = functools.partial( + override_settings, + DEFAULT_FILE_STORAGE="binary_database_files.storage.DatabaseStorage", + ) +else: + set_default_file_storage = functools.partial( + override_settings, + STORAGES={ + "default": {"BACKEND": "binary_database_files.storage.DatabaseStorage"} + }, + ) class DatabaseFilesTestCase(TestCase): From dcd85d24796a4ddc588032caba48001dd091c89b Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Wed, 18 Jun 2025 16:04:15 +0200 Subject: [PATCH 5/5] fix setup.py versions --- setup.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index c08f443..33ae1eb 100644 --- a/setup.py +++ b/setup.py @@ -52,16 +52,14 @@ def get_reqs(*fns): "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", - "Framework :: Django :: 2.2", - "Framework :: Django :: 3.0", - "Framework :: Django :: 3.1", - "Framework :: Django :: 3.2", - "Framework :: Django :: 4.0", - "Framework :: Django :: 5.0", + "Programming Language :: Python :: 3.13", + "Framework :: Django :: 4.2", + "Framework :: Django :: 5.1", + "Framework :: Django :: 5.2", ], install_requires=get_reqs( "pip-requirements.txt", ), tests_require=get_reqs("pip-requirements-test.txt"), - python_requires=">=3.6,<3.13", + python_requires=">=3.6", )