Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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

MIT

Project details


Release history Release notifications

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.

Files for django-filestorages, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_filestorages-0.1-py3-none-any.whl (3.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size django-filestorages-0.1.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page