Skip to content

Commit 515a099

Browse files
Drop support for Django 3.2 (#589)
* Drop support for Django 3.2 * use django STORAGES setting --------- Co-authored-by: Archmonger <16909269+Archmonger@users.noreply.github.com>
1 parent 91e3611 commit 515a099

File tree

14 files changed

+101
-90
lines changed

14 files changed

+101
-90
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"editor.defaultFormatter": "vscode.json-language-features"
2525
},
2626
"[python]": {
27-
"editor.defaultFormatter": "ms-python.python"
27+
"editor.defaultFormatter": "charliermarsh.ruff"
2828
},
2929
"html.format.endWithNewline": true,
3030
"files.insertFinalNewline": true

README.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ Django Database Backup
88
:target: https://django-dbbackup.readthedocs.io/
99
:alt: Documentation Status
1010

11-
.. image:: https://codecov.io/gh/Archmonger/django-dbbackup/branch/master/graph/badge.svg?token=zaYmStcsuX
12-
:target: https://codecov.io/gh/Archmonger/django-dbbackup
13-
1411
This Django application provides management commands to help backup and
1512
restore your project database and media files with various storages such as
1613
Amazon S3, Dropbox, local file storage or any Django storage.
@@ -51,4 +48,3 @@ We use GitHub Actions as continuous integration tools.
5148
.. _`Read The Docs`: https://django-dbbackup.readthedocs.org/
5249
.. _`GitHub issues`: https://github.com/Archmonger/django-dbbackup/issues
5350
.. _`pull requests`: https://github.com/Archmonger/django-dbbackup/pulls
54-
.. _Coveralls: https://coveralls.io/github/Archmonger/django-dbbackup

dbbackup/checks.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@
4848
"Did you mean to change the value for 'location'?",
4949
id="dbbackup.W007",
5050
)
51+
W009 = Warning(
52+
"Using removed DBBACKUP_STORAGE parameter",
53+
hint="settings.DBBACKUP_STORAGE has been removed in favor of settings.STORAGES['dbbackup']",
54+
id="dbbackup.W009",
55+
)
56+
W010 = Warning(
57+
"Using removed DBBACKUP_STORAGE_OPTIONS parameter",
58+
hint="settings.DBBACKUP_STORAGE_OPTIONS has been removed in favor of settings.STORAGES['dbbackup']['OPTIONS']",
59+
id="dbbackup.W010",
60+
)
5161

5262

5363
def check_filename_templates():
@@ -107,4 +117,10 @@ def check_settings(app_configs, **kwargs):
107117

108118
errors += check_filename_templates()
109119

120+
if getattr(settings, "DBBACKUP_STORAGE", None) is not None:
121+
errors.append(W009)
122+
123+
if getattr(settings, "DBBACKUP_STORAGE_OPTIONS", None) is not None:
124+
errors.append(W010)
125+
110126
return errors

dbbackup/settings.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,13 @@
3535
GPG_ALWAYS_TRUST = getattr(settings, "DBBACKUP_GPG_ALWAYS_TRUST", False)
3636
GPG_RECIPIENT = GPG_ALWAYS_TRUST = getattr(settings, "DBBACKUP_GPG_RECIPIENT", None)
3737

38-
STORAGE = getattr(settings, "DBBACKUP_STORAGE", None)
39-
STORAGE_OPTIONS = getattr(settings, "DBBACKUP_STORAGE_OPTIONS", {})
40-
# https://docs.djangoproject.com/en/5.1/ref/settings/#std-setting-STORAGES
4138
STORAGES_DBBACKUP_ALIAS = "dbbackup"
4239
DJANGO_STORAGES = getattr(settings, "STORAGES", {})
43-
django_dbbackup_storage = DJANGO_STORAGES.get(STORAGES_DBBACKUP_ALIAS, {})
44-
45-
if not STORAGE:
46-
STORAGE = (
47-
django_dbbackup_storage.get("BACKEND")
48-
or "django.core.files.storage.FileSystemStorage"
49-
)
50-
if not STORAGE_OPTIONS:
51-
STORAGE_OPTIONS = django_dbbackup_storage.get("OPTIONS") or STORAGE_OPTIONS
40+
storage: dict = DJANGO_STORAGES.get(STORAGES_DBBACKUP_ALIAS, {})
41+
STORAGE = storage.get("BACKEND", "django.core.files.storage.FileSystemStorage")
42+
STORAGE_OPTIONS = storage.get("OPTIONS", {})
5243

5344
CONNECTORS = getattr(settings, "DBBACKUP_CONNECTORS", {})
54-
5545
CUSTOM_CONNECTOR_MAPPING = getattr(settings, "DBBACKUP_CONNECTOR_MAPPING", {})
5646

5747
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

dbbackup/storage.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def get_storage(path=None, options=None):
1414
Get the specified storage configured with options.
1515
1616
:param path: Path in Python dot style to module containing the storage
17-
class. If empty settings.DBBACKUP_STORAGE will be used.
17+
class. If empty settings.STORAGES["dbbackup"] will be used.
1818
:type path: ``str``
1919
2020
:param options: Parameters for configure the storage, if empty
21-
settings.DBBACKUP_STORAGE_OPTIONS will be used.
21+
settings.STORAGES["dbbackup"]["OPTIONS"] will be used.
2222
:type options: ``dict``
2323
2424
:return: Storage configured
@@ -28,7 +28,7 @@ def get_storage(path=None, options=None):
2828
options = options or settings.STORAGE_OPTIONS
2929
if not path:
3030
raise ImproperlyConfigured(
31-
"You must specify a storage class using " "DBBACKUP_STORAGE settings."
31+
'You must specify a storage class using settings.STORAGES["dbbackup"] settings.'
3232
)
3333
return Storage(path, **options)
3434

@@ -59,7 +59,7 @@ def __init__(self, storage_path=None, **options):
5959
Initialize a Django Storage instance with given options.
6060
6161
:param storage_path: Path to a Django Storage class with dot style
62-
If ``None``, ``settings.DBBACKUP_STORAGE`` will
62+
If ``None``, ``settings.STORAGES["dbbackup"]`` will
6363
be used.
6464
:type storage_path: str
6565
"""

dbbackup/tests/settings.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,20 @@
5555
DBBACKUP_GPG_RECIPIENT = "test@test"
5656
DBBACKUP_GPG_ALWAYS_TRUST = (True,)
5757

58-
DBBACKUP_STORAGE = os.environ.get("STORAGE", "dbbackup.tests.utils.FakeStorage")
59-
DBBACKUP_STORAGE_OPTIONS = dict(
60-
[
61-
keyvalue.split("=")
62-
for keyvalue in os.environ.get("STORAGE_OPTIONS", "").split(",")
63-
if keyvalue
64-
]
65-
)
66-
67-
# For testing the new storages setting introduced in Django 4.2
6858
STORAGES = {
6959
"default": {
7060
"BACKEND": "django.core.files.storage.FileSystemStorage",
7161
"OPTIONS": {},
7262
},
7363
"dbbackup": {
74-
"BACKEND": DBBACKUP_STORAGE,
75-
"OPTIONS": DBBACKUP_STORAGE_OPTIONS,
64+
"BACKEND": os.environ.get("STORAGE", "dbbackup.tests.utils.FakeStorage"),
65+
"OPTIONS": dict(
66+
[
67+
keyvalue.split("=")
68+
for keyvalue in os.environ.get("STORAGE_OPTIONS", "").split(",")
69+
if keyvalue
70+
]
71+
),
7672
},
7773
}
7874

dbbackup/tests/test_storage.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ def test_set_options(self, *args):
2626
storage = get_storage(options=STORAGE_OPTIONS)
2727
self.assertIn(
2828
storage.storage.__module__,
29-
# TODO: Remove "django.core.files.storage" case when dropping support for Django < 4.2.
30-
("django.core.files.storage", "django.core.files.storage.filesystem"),
29+
{"django.core.files.storage.filesystem"},
3130
)
3231

3332
def test_get_storage_class(self):
3433
storage_class = get_storage_class(DEFAULT_STORAGE_PATH)
3534
self.assertIn(
3635
storage_class.__module__,
37-
("django.core.files.storage", "django.core.files.storage.filesystem"),
36+
{"django.core.files.storage.filesystem"},
3837
)
3938
self.assertIn(storage_class.__name__, ("FileSystemStorage", "DefaultStorage"))
4039

@@ -46,7 +45,7 @@ def test_default_storage_class(self):
4645
storage_class = get_storage_class()
4746
self.assertIn(
4847
storage_class.__module__,
49-
("django.core.files.storage", "django.core.files.storage.filesystem"),
48+
{"django.core.files.storage"},
5049
)
5150
self.assertIn(storage_class.__name__, ("FileSystemStorage", "DefaultStorage"))
5251

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Unreleased
77
* Use environment variable for PostgreSQL password to prevent password leakage in logs/emails
88
* This repository has been transferred out of Jazzband due to logistical concerns.
99
* Drop support for end-of-life Python 3.7 and 3.8.
10+
* Drop support for end-of-life Django 3.2.
11+
* Drop support for ``DBBACKUP_STORAGE`` AND ``DBBACKUP_STORAGE_OPTIONS`` settings, use Django's ``STORAGES['dbbackup']`` setting instead.
1012

1113
4.3.0 (2025-05-09)
1214
----------

docs/index.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ Contents:
2929
contributing
3030
changelog
3131

32-
Compatibility
33-
-------------
34-
35-
As we want to ensure a lot of platforms will be able to save data before
36-
upgrading, Django-DBBackup supports PyPy, 3.2 to 3.5 and Django
37-
greater than 3.2.
38-
3932
Other Resources
4033
===============
4134

docs/installation.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ In your ``settings.py``, make sure you have the following things: ::
3737
'dbbackup', # django-dbbackup
3838
)
3939

40-
DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage'
41-
DBBACKUP_STORAGE_OPTIONS = {'location': '/my/backup/dir/'}
40+
STORAGES = {
41+
'dbbackup': {
42+
'BACKEND': 'django.core.files.storage.FileSystemStorage',
43+
'OPTIONS': {
44+
'location': '/my/backup/dir/',
45+
},
46+
},
47+
}
4248

4349
Create the backup directory: ::
4450

0 commit comments

Comments
 (0)