Skip to main content

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"


# Optional. For example, `static/`. If not set, files will be stored in the
# storage's root dir.
BUNNY_BASE_DIR = "my-storage-base-dir-where-i-want-my-files-stored/"

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",

            # Optional. `BUNNY_BASE_DIR` will be used if it is not set.
            "base_dir": "my-storage-base-dir-where-i-want-my-files-stored/"
        }
    },
}

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_bunny-1.1.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_bunny-1.1.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file django_bunny-1.1.3.tar.gz.

File metadata

  • Download URL: django_bunny-1.1.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.11 Windows/10

File hashes

Hashes for django_bunny-1.1.3.tar.gz
Algorithm Hash digest
SHA256 4c9c67837d9711c3ac1104d3b0a79b120fc6bd11f39e6f2f048d63de22dd86c2
MD5 d7233fb6b0f4cd15bd5288931631aa25
BLAKE2b-256 0d4cc6832785f187d79f7d776212bf62ab56ca2b32f8e7405b410fd4686a23a6

See more details on using hashes here.

File details

Details for the file django_bunny-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: django_bunny-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.11 Windows/10

File hashes

Hashes for django_bunny-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c3a0cb36794ec762e62fe1fc29cb6d0914fc0be3c119e38e94ff952c52cf10bb
MD5 c53e5f51d05adf880d8e7ac9404c66fe
BLAKE2b-256 bff169b0813eb927aa5f2a7f2665086ca73b6ab66edcb63ee7d6d4ede862f69d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page