Skip to content

meringue.conf.default_settings ¤

UPLOAD_RENAME_HANDLER module-attribute ¤

UPLOAD_RENAME_HANDLER: Final[str] = (
    "meringue.core.upload_handlers.rename_handler"
)

Path to method for renaming images on upload

COP_YEAR module-attribute ¤

COP_YEAR: Final[int | None] = None

Project start year for the copyright tag

COP_YEARS_DIFF module-attribute ¤

COP_YEARS_DIFF: Final[int] = 10

Difference in years for which it is necessary to display the range of years

Specify 1 to display the period for the second year.

CRYPTO_KEY module-attribute ¤

CRYPTO_KEY: Final[str] = settings.SECRET_KEY[:32]

Encryption key

FRONTEND_URLS module-attribute ¤

FRONTEND_URLS: Final[dict | None] = None

A dict of links to the frontend

FRONTEND_DOMAIN module-attribute ¤

FRONTEND_DOMAIN: Final[str | None] = None

Domain for generating absolute links

API_ENABLE_ROOT_VIEW module-attribute ¤

API_ENABLE_ROOT_VIEW: Final[bool] = settings.DEBUG

Option to enable or disable the root view of the Router

THUMBNAIL_GENERATOR_CLASS module-attribute ¤

THUMBNAIL_GENERATOR_CLASS: Final[str] = (
    "meringue.thumbnail.generators.Thumbnailer"
)

Thumbnail generator class.

THUMBNAIL_STORAGE_GETTER module-attribute ¤

THUMBNAIL_STORAGE_GETTER: Final[str] = (
    "meringue.thumbnail.storage.get_storage"
)

Dotted path to a method that returns a store.

THUMBNAIL_IMAGE_CLASS module-attribute ¤

THUMBNAIL_IMAGE_CLASS: Final[str] = (
    "meringue.thumbnail.images.ThumbnailImage"
)

Thumbnail image class.

THUMBNAIL_DIR module-attribute ¤

THUMBNAIL_DIR: Final[Path] = Path(
    settings.MEDIA_ROOT
) / Path("m/thumbnail")

Directory for saving thhumbnails.

THUMBNAIL_URL module-attribute ¤

THUMBNAIL_URL: Final[str] = urljoin(
    settings.MEDIA_URL, "m/thumbnail"
)

Url where thumbnails will be available.

THUMBNAIL_PROPERTIES module-attribute ¤

THUMBNAIL_PROPERTIES: Final[dict[str, str]] = {
    "cm": "meringue.thumbnail.properties.set_crop_method",
    "rm": "meringue.thumbnail.properties.set_resize_method",
    "rs": "meringue.thumbnail.properties.set_resize_strategy",
    "s": "meringue.thumbnail.properties.set_size",
    "maxw": "meringue.thumbnail.properties.set_max_width",
    "maxh": "meringue.thumbnail.properties.set_max_height",
    "c": "meringue.thumbnail.properties.set_bg_color",
}

Registered thumbnail properties.

THUMBNAIL_ACTIONS module-attribute ¤

THUMBNAIL_ACTIONS: Final[dict[str, str]] = {
    "crop": "meringue.thumbnail.actions.crop",
    "resize": "meringue.thumbnail.actions.resize",
}

Registered thumbnail actions.

THUMBNAIL_DEFAULT_CROP_METHOD module-attribute ¤

THUMBNAIL_DEFAULT_CROP_METHOD: Final[list[str]] = [
    "center",
    "center",
]

Default crop method.

THUMBNAIL_DEFAULT_RESIZE_METHOD module-attribute ¤

THUMBNAIL_DEFAULT_RESIZE_METHOD: Final[str] = 'contain'

Default resize method.

THUMBNAIL_DEFAULT_RESIZE_STRATEGY module-attribute ¤

THUMBNAIL_DEFAULT_RESIZE_STRATEGY: Final[str] = 'standard'

Default resize strategy.

THUMBNAIL_DEFAULT_BG_COLOR module-attribute ¤

THUMBNAIL_DEFAULT_BG_COLOR: Final[tuple[int]] = (
    200,
    200,
    200,
    0,
)

Default background color for crop in RGBA format.

THUMBNAIL_SAVE_PARAMS_BY_FORMAT module-attribute ¤

THUMBNAIL_SAVE_PARAMS_BY_FORMAT: Final[dict[str, dict]] = {
    "GIF": {"optimize": True},
    "JPEG": {"quality": 85, "optimize": True},
    "PNG": {"optimize": True, "compress_level": 5},
    "TIFF": {"quality": 85},
    "WEBP": {"quality": 85},
}

List of default options for saving thumbnails images by format.

THUMBNAIL_IMAGE_OPTIMIZE_HANDLER module-attribute ¤

THUMBNAIL_IMAGE_OPTIMIZE_HANDLER: Final[str | None] = (
    "meringue.thumbnail.optimizers.optimize"
)

Dotted path to a function that optimizes thumbnail image before saving it to storage. The function receives a ThumbnailImage instance and an in-memory image file and must return an in-memory image file.

THUMBNAIL_OPTIMIZERS module-attribute ¤

THUMBNAIL_OPTIMIZERS: Final[dict[str, dict]] = {}

Built-in thumbnail optimizer settings.

Keys are optimizer names, values are optimizer-specific settings. Empty dictionary disables built-in optimizers.

For oxipng, set binary to the oxipng executable path or command name. The default command-line options can be overridden with the options value, as either a string or a list of strings.

Example
{
    "oxipng": {
        "binary": "oxipng",
        "options": "-o 4 --strip all",
    },
}

THUMBNAIL_DUMMYIMAGE_TEMPLATE module-attribute ¤

THUMBNAIL_DUMMYIMAGE_TEMPLATE: Final[str] = (
    "//dummyimage.com/{width}x{height}/9e9e9e/424242.png"
)

Template for dummy image URL in DEBUG mode. Supports {static_url}, {width} and {height} placeholders (STATIC_URL and the final size of the thumbnail job chain).

THUMBNAIL_DUMMYIMAGE_URL module-attribute ¤

THUMBNAIL_DUMMYIMAGE_URL: Final[str] = (
    "{static_url}images/noise.png"
)

Dummy image URL when DEBUG is off (see get_dummy_image_url). Supports {static_url} (STATIC_URL at the moment of the call), {width} and {height} (the final size of the thumbnail job chain) placeholders. The default images/noise.png is shipped with the meringue.thumbnail static files.

Examples:

MERINGUE = {
    "THUMBNAIL_DUMMYIMAGE_URL": "{static_url}img/no-image.svg",
}

THUMBNAIL_DEFAULT_FORMAT module-attribute ¤

THUMBNAIL_DEFAULT_FORMAT: Final[str] = 'PNG'

Default thumbnail image format.

THUMBNAIL_CACHE module-attribute ¤

THUMBNAIL_CACHE: Final[str | None] = None

Alias of the Django cache (from CACHES) for thumbnail marks and locks. None disables it.

With the cache:

  • the "thumbnail is saved" mark is kept in the cache, so the thumbnail storage is checked only once per THUMBNAIL_CACHE_TIMEOUT (useful for remote storages like S3);
  • only one process makes a new thumbnail: the lock is taken with cache.add.

Use a cache shared by all processes (Redis, Memcached, database) for the lock to work.

THUMBNAIL_CACHE_TIMEOUT module-attribute ¤

THUMBNAIL_CACHE_TIMEOUT: Final[int | None] = (
    60 * 60 * 24 * 7
)

Timeout (in seconds) of the "thumbnail is saved" mark in THUMBNAIL_CACHE. None means forever.

THUMBNAIL_CACHE_LOCK_TIMEOUT module-attribute ¤

THUMBNAIL_CACHE_LOCK_TIMEOUT: Final[int] = 60

Timeout (in seconds) of the thumbnail generation lock in THUMBNAIL_CACHE.

PROTECTED_SERVE_WITH_NGINX module-attribute ¤

PROTECTED_SERVE_WITH_NGINX: Final[bool] = not settings.DEBUG

The option implies the distribution of protected files by nginx. Instead of serving the file in response.

The view x_accel_redirect_view adds the X-Accel-Redirect header with a link to the file.

PROTECTED_NGINX_LOCATION_GETTER module-attribute ¤

PROTECTED_NGINX_LOCATION_GETTER: Final[str] = (
    "meringue.protected.utils.nginx_location_getter"
)

Default getter for the link to the file where nginx should serve it after access verification.