Provides Bunny.net file storage in Django.
Project description
django-bunny-storage
Provides Bunny.net file storage in Django.
Installation
django-bunny-storage
requires Python >= 3.7.
pip install django-bunny-storage
Configuration
Everything is configured in your settings.py
file.
To use:
- Add
django_bunny_storage
to yourINSTALLED_APPS
.
INSTALLED_APPS = [
...
'django_bunny_storage'
]
- Add
BUNNY_USERNAME
andBUNNY_PASSWORD
to your settings.
BUNNY_USERNAME = 'myzone'
BUNNY_PASSWORD = 'myzone-random-password-string'
# Optional
BUNNY_REGION = 'de'
These settings correspond to your storage zone's Username and Password found under FTP & API Access in your Bunny.net Storage dashboard.
You must include BUNNY_REGION
if the default region, NY, does not match the region you set yourself.
- Change your media url and default file storage backend.
DEFAULT_FILE_STORAGE = 'django_bunny_storage.storage.BunnyStorage'
MEDIA_URL = 'https://myzone.b-cdn.net/' # The Pull Zone hostname.
The MEDIA_URL
is set based on a linked Pull Zone that you setup in the Bunny.net dashboard.
In Templates
In order to display your media properly in templates, refer to Django's docs on the MEDIA_URL attribute to ensure you're not getting 404s when trying to load media.
Whenever referencing media, do
<img src="{{ MEDIA_URL }}{{ mymodel.file }}" />
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for django_bunny_storage-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbbb9c6fa4643eb34ac274c3676da2a161b66aee480fe41e7f51c594f2e5b02d |
|
MD5 | 039f56307e26db18abe6bead126b188a |
|
BLAKE2b-256 | eff5d35475a1679e3b7771dda9e05d486a704a7ead71458185b3a52aa9134ac4 |