Skip to main content

Configurable file storages for Django

None

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

MIT

Project details

None

Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-filestorages-0.1.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

django_filestorages-0.1-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page