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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5652c852f4dfbcff68c7540c3e757fcbbd6131816341fc3447cd0fdedce278c |
|
MD5 | 6e832819c35a4a71d99169b9fe4c7df6 |
|
BLAKE2b-256 | 6c651bdf7afc5840ae9bfbd37ef491106f06f1885d816fac086bf2d25a55b1e8 |
Hashes for django_cloudflare_images-0.3.1-py3.10.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56e5e3b4edd93d78971c0aa2339485918a9c02931cbcbc71fc068c503afa043b |
|
MD5 | f729b9bb225b0d777983752041536ea5 |
|
BLAKE2b-256 | 4430044a36fad441782ab17822606ffc93ba8fb15c44771c841b85e909ea84d8 |