Cloudflare Images integration for Django
Project description
django-cloudflare-images
This is a Django library to add support to Cloudflare Images to the ImageField.
Installation
pip install django-cloudflare-images
Setup
You need to add the following your settings.py:
DEFAULT_FILE_STORAGE = "cloudflare_images.storage.CloudflareImagesStorage"
CLOUDFLARE_IMAGES_ACCOUNT_ID = "XXX"
CLOUDFLARE_IMAGES_API_TOKEN = "YYY"
CLOUDFLARE_IMAGES_ACCOUNT_HASH = "ZZZ"
If you wish to use a default variant for a specific field you need to change your ImageField
to a CloudflareImagesField
see example below:
from cloudflare_images.field import CloudflareImagesField
from django.db import models
class MyModel(models.Model):
image = CloudflareImagesField(variant="custom")
Please note that you will need to migrate your model(s) once you swapped the field(s). No SQL will actually be applied (you can check by running sqlmigrate <module> <number>
).
If you wish to use a custom domain to serve your images you need to add the following to your settings.py:
CLOUDFLARE_IMAGES_DOMAIN = "example.com"
Development
Installing for development:
make install
Cleaning the installation:
make clean
Format the code:
make format
Running all tests:
make test
Setup.py commands:
make package-develop
make package-build
make package-install
make package-sdist
TODO
This is a list of non exhaustive list of things I would like to add to the project:
- Support global default variant instead of "public"
- Functional tests with real credentials (to be passed in the environment)
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
Hashes for django-cloudflare-images-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bafa277d6ddb8200020dc0e6d71a4e3c5556dfe9c09075b3595b39720575ed4 |
|
MD5 | e595b9349e84cb0f6a05e653bffaeebf |
|
BLAKE2b-256 | df84ddd699845d0127cd31d9cf737ba8dcac65653b57c490734e7fe2e084148e |
Hashes for django_cloudflare_images-0.3.0-py3.10.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d38831affc492d3a58376ccc82553353932d2dae5185948aad34706cbd782e4 |
|
MD5 | 7a1aea928193187a0dcdbc6e08321b31 |
|
BLAKE2b-256 | 65faf810a18c613ecd15faaff8f04e1e6d5d4cb4e0929339424f1d36526a9489 |