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"

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


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.0.5.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

django_bunny-1.0.5-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file django-bunny-1.0.5.tar.gz.

File metadata

  • Download URL: django-bunny-1.0.5.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

Hashes for django-bunny-1.0.5.tar.gz
Algorithm Hash digest
SHA256 4de86ff7e5be8bdc04151ced9afcca7d7de676990c532d06a31432c3bcc95bb7
MD5 f3c0e95ab92a963e643c429cb9142e7c
BLAKE2b-256 197447a25f41fec5ade68aa2c0358d9f405f0c330b78aafb4bfe1b6cd56d1381

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: django_bunny-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.10.7 Windows/10

File hashes

Hashes for django_bunny-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 292510b78201447915cf00b7af90c72d3f3589513f2a4476b61745c736350fc7
MD5 0c38bb4872e33f17e74c45de164d74de
BLAKE2b-256 263ea16a8edd2d41d0ec84ea71848400d4d0f16aea55a39078f56f1760efaed4

See more details on using hashes here.

Provenance

Supported by

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