django-bunny


Namedjango-bunny JSON
Version 1.1.6 PyPI version JSON
download
home_pagehttps://github.com/Nekidev/django-bunny/
SummaryA django storage for bunny.net
upload_time2023-09-07 06:01:46
maintainerNeki
docs_urlNone
authorNeki
requires_python>=3.7,<4.0
licenseMIT
keywords django bunny cdn storage django-storage
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-bunny

A bunny.net storage for Django. It was created as a replacement for [django-bunny-storage](https://github.com/willmeyers/django-bunny-storage).


## Installation

You can install the library using `pip`:

```bash
pip install django-bunny
```


## Configuration

First, add `django_bunny` to your `INSTALLED_APPS`:

```py
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.

```py
# 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:

```py
# 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:

```html
<img src="{{ instance.file.url }}" />
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Nekidev/django-bunny/",
    "name": "django-bunny",
    "maintainer": "Neki",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "neki@nekidev.com",
    "keywords": "django,bunny,cdn,storage,django-storage",
    "author": "Neki",
    "author_email": "neki@nekidev.com",
    "download_url": "https://files.pythonhosted.org/packages/24/d3/8190a8c7cf59a9dc5011898e3fc56b5c2c221d9912d2fff0508155b79336/django_bunny-1.1.6.tar.gz",
    "platform": null,
    "description": "# django-bunny\n\nA bunny.net storage for Django. It was created as a replacement for [django-bunny-storage](https://github.com/willmeyers/django-bunny-storage).\n\n\n## Installation\n\nYou can install the library using `pip`:\n\n```bash\npip install django-bunny\n```\n\n\n## Configuration\n\nFirst, add `django_bunny` to your `INSTALLED_APPS`:\n\n```py\nINSTALLED_APPS = [\n    ...,\n    \"django_bunny\",\n    ...\n]\n```\n\nNow, 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.\n\n```py\n# These can be found in your storage's dashboard under `FTP & API Access`\nBUNNY_USERNAME = \"my-storage-name\"\nBUNNY_PASSWORD = \"my-storage-password\"\n\n# This is the storage region's code. E.g. Los Angeles is `la`, Singapore is\n# `sg`, etc. The default is `ny` (New York).\nBUNNY_REGION = \"my-storage-region\"\n\n# Optional. For example, `https://myzone.b-cdn.net/`. `MEDIA_URL` will be used\n# if this is not set.\nBUNNY_HOSTNAME = \"my-pullzone-hostname\"\n\n\n# Optional. For example, `static/`. If not set, files will be stored in the\n# storage's root dir.\nBUNNY_BASE_DIR = \"my-storage-base-dir-where-i-want-my-files-stored/\"\n```\n\nFinally, depending on which version of Django you are using you'll need to create one of these variables:\n\n```py\n# Django < 4.2\nDEFAULT_FILE_STORAGE = 'django_bunny.storage.BunnyStorage'\n\n# Django >= 4.2. Set `BunnyStorage` where you want to use bunny.net's storage.\n{\n    \"default\": {\n        \"BACKEND\": \"django_bunny.storage.BunnyStorage\",\n\n        # Add this if you did not create the BUNNY_* settings before. They are\n        # the same as BUNNY_* variables.\n        \"OPTIONS\": {\n            \"username\": \"my-storage-name\",\n            \"password\": \"my-storage-password\",\n            \n            # Optional. Defaults to `ny`\n            \"region\": \"my-storage-region\",\n            \n            # Optional. `MEDIA_URL` will be used if it is not set\n            \"hostname\": \"my-pullzone-hostname\",\n\n            # Optional. `BUNNY_BASE_DIR` will be used if it is not set.\n            \"base_dir\": \"my-storage-base-dir-where-i-want-my-files-stored/\"\n        }\n    },\n}\n```\n\nIn 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.\n\n\n## Using in templates\n\nIn templates, you can use `{{ instance.file.url }}` directly. For example:\n\n```html\n<img src=\"{{ instance.file.url }}\" />\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A django storage for bunny.net",
    "version": "1.1.6",
    "project_urls": {
        "Documentation": "https://github.com/Nekidev/django-bunny/tree/main/README.md",
        "Homepage": "https://github.com/Nekidev/django-bunny/",
        "Repository": "https://github.com/Nekidev/django-bunny/"
    },
    "split_keywords": [
        "django",
        "bunny",
        "cdn",
        "storage",
        "django-storage"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b611d4a896233bd792ef26349f03ee828acae43c9256aa8bd63b28d918167492",
                "md5": "30906f41b744f978b240282065b4994c",
                "sha256": "ccfd02286b7726284a94ee5991dfd116e040af703c5f578cad6be519a7e6b43b"
            },
            "downloads": -1,
            "filename": "django_bunny-1.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "30906f41b744f978b240282065b4994c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 4805,
            "upload_time": "2023-09-07T06:01:44",
            "upload_time_iso_8601": "2023-09-07T06:01:44.358565Z",
            "url": "https://files.pythonhosted.org/packages/b6/11/d4a896233bd792ef26349f03ee828acae43c9256aa8bd63b28d918167492/django_bunny-1.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "24d38190a8c7cf59a9dc5011898e3fc56b5c2c221d9912d2fff0508155b79336",
                "md5": "f1c3b9d8a79b484c12fac4abf0722ea2",
                "sha256": "753b29a8f56ab7cf985487a84e23047443fb450d241e7f11615ec963d83fd84a"
            },
            "downloads": -1,
            "filename": "django_bunny-1.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "f1c3b9d8a79b484c12fac4abf0722ea2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 4414,
            "upload_time": "2023-09-07T06:01:46",
            "upload_time_iso_8601": "2023-09-07T06:01:46.122402Z",
            "url": "https://files.pythonhosted.org/packages/24/d3/8190a8c7cf59a9dc5011898e3fc56b5c2c221d9912d2fff0508155b79336/django_bunny-1.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-07 06:01:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Nekidev",
    "github_project": "django-bunny",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-bunny"
}
        
Elapsed time: 0.10842s