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"
If you wish to use a default variant other than "public" to serve your images you need to add the following to your settings.py:
CLOUDFLARE_IMAGES_VARIANT = "custom"
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
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.4.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a0a421a3061cbdde71372bf0d3ffcac1469ca40d9f2c2dbcbf551753b0a9951 |
|
MD5 | c0486c93d43600d00e72c4fbb5a1cccd |
|
BLAKE2b-256 | 438a176f9772941f39444bdcfd03a1d0daa33a0dc537781adb165f0f335fc6b9 |
Hashes for django_cloudflare_images-0.4.1-py3.10.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e62cb67f6239fb0431982cb8fb09b0363d65765d53aa0146c1eaa780c5da309 |
|
MD5 | abb5f4b0ebb243c9dc2ed90e5ad14cef |
|
BLAKE2b-256 | 6bb1fe6e9774aa48e3b2caefc29234a8827d81469de9c851c0337dfdc9b85bdb |