Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
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
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions binary_database_files/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
12 changes: 5 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
14 changes: 7 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}-django{50},py{310,311,312,313}-django{51,52}
recreate = True

[gh-actions]
Expand All @@ -14,6 +14,7 @@ python =
3.10: py310
3.11: py311
3.12: py312
3.13: py313

[testenv]
basepython =
Expand All @@ -22,12 +23,11 @@ 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.*
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:}