Skip to content

Commit

Permalink
Support Django 4.2 and Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
sastred committed May 5, 2023
1 parent 028307f commit ae7f3cd
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Change log
==========

v1.5.0 (2023-05-08)
--------------------

* Support Python 3.11 and Django 4.2

v1.4.2 (2023-01-19)
--------------------

Expand Down
15 changes: 14 additions & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ We need to configure two files of our project: ``manage.py`` and ``wsgi.py``
execute_from_command_line(sys.argv)
* wsgi.py

.. code-block:: python
Expand All @@ -65,3 +64,17 @@ We need to configure two files of our project: ``manage.py`` and ``wsgi.py``
application = get_wsgi_application()
If you need or prefer to use asgi instead of wsgi:

* asgi.py

.. code-block:: python
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings")
os.environ.setdefault("DJANGO_CONFIGURATION", "Base")
from configurations.asgi import get_asgi_application
application = get_asgi_application()
8 changes: 7 additions & 1 deletion docs/mixins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,13 @@ Look at http://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html
**Parameters**

**DEFAULT_FILE_STORAGE**
By default: ``storages.backends.s3boto3.S3Boto3Storage``. For tests it might be convenient to change it by ``django.core.files.storage.FileSystemStorage``.
By default: ``storages.backends.s3boto3.S3Boto3Storage``. For tests it might be convenient to change it to ``django.core.files.storage.FileSystemStorage``. Only in Django versions < 4.2.

**DEFAULT_BACKEND_STORAGE**
By default: ``storages.backends.s3boto3.S3Boto3Storage``. For tests it might be convenient to change it to ``django.core.files.storage.FileSystemStorage``. Only in Django versions >= 4.2.

**STATICFILES_BACKEND_STORAGE**
By default: ``django.contrib.staticfiles.storage.StaticFilesStorage``Only in Django versions >= 4.2.
**AWS_S3_SIGNATURE_VERSION**
By default ``s3v4``.
Expand Down
2 changes: 1 addition & 1 deletion kaio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from .options import Options # noqa


__VERSION__ = '1.4.2'
__VERSION__ = '1.5.0'
28 changes: 23 additions & 5 deletions kaio/mixins/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@

from functools import partial

import django
from kaio import Options


opts = Options()
get = partial(opts.get, section='Storage')


class StorageMixin(object):
class _BaseStorage(object):
"""Settings for django-storages
Currently only supports AWS S3 with and without CloudFront.
"""

# AWS S3 settings: http://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html

@property
def DEFAULT_FILE_STORAGE(self):
return get('DEFAULT_FILE_STORAGE', 'storages.backends.s3boto3.S3Boto3Storage')

@property
def AWS_S3_SIGNATURE_VERSION(self):
return get('AWS_S3_SIGNATURE_VERSION', 's3v4')
Expand Down Expand Up @@ -60,3 +57,24 @@ def AWS_QUERYSTRING_AUTH(self):
@property
def AWS_DEFAULT_ACL(self):
return get('AWS_DEFAULT_ACL', 'private')


if django.VERSION[:2] < (4, 2):
class StorageMixin(_BaseStorage):
@property
def DEFAULT_FILE_STORAGE(self):
return get('DEFAULT_FILE_STORAGE', 'storages.backends.s3boto3.S3Boto3Storage')
else:
class StorageMixin(_BaseStorage):
@property
def STORAGES(self):
return {
"default": {
"BACKEND": get('DEFAULT_BACKEND_STORAGE',
'storages.backends.s3boto3.S3Boto3Storage')
},
"staticfiles": {
"BACKEND": get('STATICFILES_BACKEND_STORAGE',
'django.contrib.staticfiles.storage.StaticFilesStorage')
},
}
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Framework :: Django',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
Expand All @@ -63,6 +65,9 @@
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
],
include_package_data=True,
zip_safe=False,
Expand Down

0 comments on commit ae7f3cd

Please sign in to comment.