Skip to main content

The django-minio-backend provides a wrapper around the MinIO Python Library.

Project description

django-app-tests publish-py-dist-to-pypi PYPI


The django-minio-backend provides a wrapper around the MinIO Python SDK. See minio/minio-py for the source.


  1. Get and install the package:
pip install django-minio-backend
  1. Add django_minio_backend to INSTALLED_APPS:
    # '...'
    'django_minio_backend',  #

If you would like to enable on-start consistency check, install via DjangoMinioBackendConfig:

    # '...'
    'django_minio_backend.apps.DjangoMinioBackendConfig',  #

Then add the following parameter to your settings file:


Note: The on-start consistency check equals to manually calling python initialize_buckets.
It is recommended to turn off this feature during development by setting MINIO_CONSISTENCY_CHECK_ON_START to False, because this operation can noticeably slow down Django's boot time when many buckets are configured.

  1. Add the following parameters to your
from datetime import timedelta
from typing import List, Tuple

MINIO_ACCESS_KEY = 'yourMinioAccessKey'
MINIO_SECRET_KEY = 'yourVeryS3cr3tP4ssw0rd'
MINIO_URL_EXPIRY_HOURS = timedelta(days=1)  # Default is 7 days (longest) if not defined
MINIO_POLICY_HOOKS: List[Tuple[str, dict]] = []
  1. Implement your own Attachment handler and integrate django-minio-backend:
from django.db import models
from django_minio_backend import MinioBackend, iso_date_prefix

class PrivateAttachment(models.Model):   
    file = models.FileField(verbose_name="Object Upload",
  1. Initialize the buckets & set their public policy (OPTIONAL):
    This django-admin command creates both the private and public buckets in case one of them does not exists, and sets the public bucket's privacy policy from private(default) to public.
python initialize_buckets

Code reference:

Health Check

To check the connection link between Django and MinIO, use the provided MinioBackend.is_minio_available() method.
It returns a MinioServerStatus instance which can be quickly evaluated as boolean.


from django_minio_backend import MinioBackend

minio_available = MinioBackend('').is_minio_available()  # An empty string is fine this time
if minio_available:

Policy Hooks

You can configure django-minio-backend to automatically execute a set of pre-defined policy hooks.
Policy hooks can be defined in by adding MINIO_POLICY_HOOKS which must be a list of tuples.
Policy hooks are automatically picked up by the initialize_buckets management command.

For an exemplary policy, see the implementation of def set_bucket_to_public(self) in django_minio_backend/ or the contents of examples/

Consistency Check On Start

When enabled, the initialize_buckets management command gets called automatically when Django starts.
This command connects to the configured minIO server and checks if all buckets defined in
In case a bucket is missing or its configuration differs, it gets created and corrected.

Reference Implementation

For a reference implementation, see Examples.


  • Django 2.2 or later
  • Python 3.6.0 or later
  • MinIO SDK 7.0.2 or later

Note: This library relies heavily on PEP 484 -- Type Hints which was introduced in Python 3.5.0.


Please find the details in


  • theriverman/django-minio-backend licensed under the MIT License
  • minio/minio-py is licensed under the Apache License 2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-minio-backend, version 2.6.0
Filename, size File type Python version Upload date Hashes
Filename, size django_minio_backend-2.6.0-py3-none-any.whl (21.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-minio-backend-2.6.0.tar.gz (18.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page