A django storage for bunny.net
Project description
django-bunny
A bunny.net storage for Django. It was created as a replacement for django-bunny-storage.
Installation
You can install the library using pip
:
pip install django-bunny
Configuration
First, add django_bunny
to your INSTALLED_APPS
:
INSTALLED_APPS = [
...,
"django_bunny",
...
]
Now, create the following variables inside your settings.py
file. These are required if you are using Django < 4.2
. Otherwise, you can use OPTIONS
in the STORAGES
setting.
# These can be found in your storage's dashboard under `FTP & API Access`
BUNNY_USERNAME = "my-storage-name"
BUNNY_PASSWORD = "my-storage-password"
# This is the storage region's code. E.g. Los Angeles is `la`, Singapore is
# `sg`, etc. The default is `ny` (New York).
BUNNY_REGION = "my-storage-region"
# Optional. For example, `https://myzone.b-cdn.net/`. `MEDIA_URL` will be used
# if this is not set.
BUNNY_HOSTNAME = "my-pullzone-hostname"
Finally, depending on which version of Django you are using you'll need to create one of these variables:
# Django < 4.2
DEFAULT_FILE_STORAGE = 'django_bunny.storage.BunnyStorage'
# Django >= 4.2. Set `BunnyStorage` where you want to use bunny.net's storage.
{
"default": {
"BACKEND": "django_bunny.storage.BunnyStorage",
# Add this if you did not create the BUNNY_* settings before. They are
# the same as BUNNY_* variables.
"OPTIONS": {
"username": "my-storage-name",
"password": "my-storage-password",
# Optional. Defaults to `ny`
"region": "my-storage-region",
# Optional. `MEDIA_URL` will be used if it is not set
"hostname": "my-pullzone-hostname"
}
},
}
In Django >= 4.2 you can set different credentials for the different storages. This allows you to, for example, use a separate storage for static files.
Using in templates
In templates, you can use {{ instance.file.url }}
directly. For example:
<img src="{{ instance.file.url }}" />
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file django-bunny-1.0.12.tar.gz
.
File metadata
- Download URL: django-bunny-1.0.12.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0 CPython/3.10.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6548c0501eafc24acd411634ff341237e81d3b48277a3ddcbfbeb0cf3e373e0 |
|
MD5 | 5381589bb0ca469d2183691d343a6e84 |
|
BLAKE2b-256 | 01085b221c9b2c32f4051252be244923c611d518443229552a53a4c9958f95fc |
Provenance
File details
Details for the file django_bunny-1.0.12-py3-none-any.whl
.
File metadata
- Download URL: django_bunny-1.0.12-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0 CPython/3.10.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7eb4c1165e42931b616a560fd676a0e1f4300973171c9ae70fa26af2c0434904 |
|
MD5 | 7dc2e53dd5264fdd46dae2fdef2b4d65 |
|
BLAKE2b-256 | b60c83e992154f3d1729841cb91b3d19d545dc74be672a26ec2742499f1fa6bd |