Provides a Django storage implementation that uses a single database table.
Project description
This Python package provides a Django storage implementation that uses a single database table.
Django developers may find this package may be most useful for use in their test environments. This package may also be useful in launching small-scale projects/environments quickly without needing additional infrastructure setup.
WARNING: For production applications, please consider using a CDN instead of this package, as it is not a good practice to serve files from a database. Website performance will suffer! Please see the section "Alternatives" below for performant and scalable storage options.
Features / Benefits
- Easy to install and configure.
- Serve files properly when there are multiple django servers under a load balancer.
- Files persist in database when application server is rebuilt (as long as database is not hosted on the application server).
- In unit testing scenarios, created files can be automatically "rolled back" out of existence if the unit test uses a transaction, which is how
django.test.TestCase
works.
Installation
pip install django-single-table-db-storage
Setup
In your django settings file, add 'django_single_table_db_storage'
to INSTALLED_APPS
.
INSTALLED_APPS = [
...
'django_single_table_db_storage',
...
]
Also in your django settings file, set up the default storage. It is recommended that you add a TODO to remind yourself to use a better storage in the future.
# TODO: As this project scales, a CDN or S3-compatible storage for production
# might be a better solution.
DEFAULT_FILE_STORAGE = 'django_single_table_db_storage.storage.SingleTableDbFileStorage'
Alternatives
You can find other file storage alternatives for Django here:
https://djangopackages.org/grids/g/storage-backends/
This package contains a similar and possibly better implementation to this library, depending on your use case and license that you prefer:
Project details
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-single-table-db-storage-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a992f45b28e1c462e3f69946ed619a438427befdf9dc0dd5b29f28180ca701e4 |
|
MD5 | 32c7d4eea2ab7c872bad94200b3b21e6 |
|
BLAKE2b-256 | 5e439238e7a70f0c1ecb71c2b335dc69c3a1b49ccf996b807911a6c36b7013dd |
Hashes for django_single_table_db_storage-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57a67a44011ef6914734a6ffdc5e7e9b19788e349a3c8287df492ed4fe67b813 |
|
MD5 | 7ab0a2d785c21a945e44874dd1eed419 |
|
BLAKE2b-256 | 193affa47b0f26423a43e6f1362f5323e75013340d7567ecc59d2a2901d1cb99 |