django-dbstorage
A Django file storage backend for files in the database.
Installing
The easiest way to install django-dbstorage is to use pip:
pip install django-dbstorage
Quick Start
In your Django settings file:
Add 'django-dbstorage' to INSTALLED_APPS
Set DEFAULT_FILE_STORAGE to 'django_dbstorage.storage.DatabaseStorage'
Set MEDIA_ROOT and MEDIA_URL to None.
Serving files
In your urls.py, add the following to urlpatterns:
url(r'^media/', include('django_dbstorage.urls'))
Or, if you want to specify more options, use:
url(r'^media/', include(django_dbstorage.urls.serve()))
You should set settings.MEDIA_URL to the root of this include, in this case: /media/.
If you do not wish to serve files from the database, don’t add anything to urls.py and set settings.MEDIA_URL to None.
Customizing
DatabaseStorage takes several options. To customize, subclass it and use that as DEFAULT_FILE_STORAGE. For instance:
class MyDatabaseStorage(DatabaseStorage):
def __init__(self):
super(MyDatabaseStorage, self).__init__(location='/tmp',
base_url='/files/',
uniquify_names=True)
As a convenience, there is a NonUniquifyingDatabaseStorage class which does not attempt to find a unique filename when saving. This class throws an IOError with the EEXISTS status code, when attempting to _save().
This functionality is used by other packages, such as django-randomfilenamestorage.
Metadata
Release files for django-dbstorage 1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-dbstorage-1.3.tar.gz | 10.5 kB | Without provenance | Details for django-dbstorage-1.3.tar.gz |
Release files / django-dbstorage-1.3.tar.gz
| Download URL | django-dbstorage-1.3.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9781ad01ec8ed053a1c750cf2ab3324c73648e33b9f3b40e6b0f44d5ed06aef
|
|
BLAKE2b-256 checksum How to use checksums |
e8442172137f563de6b879634cddcb9e2c7d5fab75685ba2974a17320290715e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-dbstorage 1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.