Configurable file storages for Django
Project description
django-filestorages
Django-getstorage is a tiny Python library for dealing with configurable Django storages.
It allows you to define a dictionary of file storage configurations
in your settings
and refer to them by name in your code.
It should be obsolete once Django ticket 26029 is resolved.
Installation
Use the package manager pip to install django-filestorages.
pip install django-filestorages
Usage
Wherever you need a storage, use the filestorages.get_storage
function.
from filestorages import get_storage
file = models.FileField(storage=get_storage('some.configured.storage'))
In your settings, you can define your storages using dotted paths:
FILE_STORAGES = {
'default': {
'BACKEND': "django.core.files.storage.FileSystemStorage",
'OPTIONS': {
'location': '/path/to/the/files/',
'base_url': '/files/',
}
},
'some': {
'BACKEND': 'other.backend.Storage',
'OPTIONS': {
'option': 'value',
},
},
'some.configured': {
'OPTIONS': {
'second_option': True,
},
},
}
In this example get_storage('some.configured.storage')
returns other.backend.Storage(option='value', second_option=True)
If no matching backend is found, FILE_STORAGES['default']
is used, falling back on
DEFAULT_FILE_STORAGE
if not set.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_filestorages-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53d1543314438fa91a63538e66fbb2860d547e3f56c0aa1548f34088ee4b0f79 |
|
MD5 | 85e748f3f361aa26a1a9ce6fd3f34dc2 |
|
BLAKE2b-256 | cb84ad26f495fee94b8e1a81309d5cd3055bb433e54a994e65f072950cc954d6 |