{"id":8944,"library":"django-cloudinary-storage","title":"Django Cloudinary Storage","description":"django-cloudinary-storage is a Django package that provides custom storage backends for Cloudinary, allowing both media and static files to be served from Cloudinary. It also includes management commands for file cleanup. The current version is 0.3.0, released with support for Django 2 and Python 3.6+, with infrequent releases focusing on Django version compatibility.","status":"active","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/klis87/django-cloudinary-storage","tags":["django","cloudinary","storage","media","static-files","cloud"],"install":[{"cmd":"pip install django-cloudinary-storage","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This is a Django package, requiring Django to operate.","package":"Django","optional":false},{"reason":"Required for interaction with the Cloudinary API.","package":"cloudinary","optional":false}],"imports":[{"note":"Storage classes are located within the 'storage' submodule.","wrong":"from cloudinary_storage import MediaCloudinaryStorage","symbol":"MediaCloudinaryStorage","correct":"from cloudinary_storage.storage import MediaCloudinaryStorage"},{"note":"Storage classes are located within the 'storage' submodule.","wrong":"from cloudinary_storage import StaticCloudinaryStorage","symbol":"StaticCloudinaryStorage","correct":"from cloudinary_storage.storage import StaticCloudinaryStorage"}],"quickstart":{"code":"import os\n\n# settings.py\n\nINSTALLED_APPS = [\n    # ... other Django apps ...\n    'django.contrib.staticfiles',\n    'cloudinary_storage',\n]\n\n# ... other Django settings (MIDDLEWARE, TEMPLATES, DATABASES, etc.) ...\n\n# Cloudinary Credentials (strongly recommended to use environment variables)\nCLOUDINARY_CLOUD_NAME = os.environ.get('CLOUDINARY_CLOUD_NAME', '')\nCLOUDINARY_API_KEY = os.environ.get('CLOUDINARY_API_KEY', '')\nCLOUDINARY_API_SECRET = os.environ.get('CLOUDINARY_API_SECRET', '')\n\n# Default Storage for Media Files\nDEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'\nMEDIA_URL = '/media/' # This is still needed for Django's internal URL handling\n\n# Default Storage for Static Files\nSTATICFILES_STORAGE = 'cloudinary_storage.storage.StaticCloudinaryStorage'\nSTATIC_URL = '/static/' # This is still needed for Django's internal URL handling\n\n# Optional: Configure prefixing for URLs on Cloudinary (e.g., to group files)\nCLOUDINARY_STORAGE = {\n    'MEDIA_TAG': 'media',\n    'STATIC_TAG': 'static',\n    'MEDIA_DELIVERY_URL_WITH_PREFIX': True,\n    'STATIC_DELIVERY_URL_WITH_PREFIX': True,\n    'PREFIX': os.environ.get('CLOUDINARY_URL_PREFIX', None), # e.g., 'my_django_project'\n}\n\n# Example usage in a model:\n# from django.db import models\n# class MyPhoto(models.Model):\n#     title = models.CharField(max_length=100)\n#     image = models.ImageField(upload_to='photos/%Y/%m/')\n","lang":"python","description":"To quickly integrate django-cloudinary-storage, add `'cloudinary_storage'` to `INSTALLED_APPS` and configure the Cloudinary credentials. Then, set `DEFAULT_FILE_STORAGE` for media files and `STATICFILES_STORAGE` for static files in your `settings.py`. Ensure your `CLOUDINARY_CLOUD_NAME`, `CLOUDINARY_API_KEY`, and `CLOUDINARY_API_SECRET` are correctly set, ideally via environment variables."},"warnings":[{"fix":"Disregard the 'removed Python 3 support' note. Ensure your project uses Python 3.6+.","message":"The release notes for v0.3.0 on GitHub contain a typo stating it 'removed Python 3 support'. This is incorrect. Version 0.3.0 and later actually require Python 3.6+ and are compatible with modern Django versions.","severity":"gotcha","affected_versions":"0.3.0 (documentation only)"},{"fix":"Upgrade to `django-cloudinary-storage>=0.3.0` for Django 2.x+ projects. For older Django versions, check the `install_requires` in the `setup.py` of specific releases.","message":"Version 0.3.0 explicitly added support for Django 2.x. If you are using Django 2.x or newer, ensure you are using `django-cloudinary-storage` version 0.3.0 or higher. Older versions may not be compatible.","severity":"breaking","affected_versions":"<0.3.0 when used with Django 2.x+"},{"fix":"Ensure all three environment variables or direct settings are present and hold valid Cloudinary account credentials in your `settings.py`.","message":"Cloudinary API credentials (`CLOUDINARY_CLOUD_NAME`, `CLOUDINARY_API_KEY`, `CLOUDINARY_API_SECRET`) are mandatory for the storage to authenticate and function correctly. Misconfigured or missing credentials will lead to authentication errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Add or update these settings in your `settings.py` to enable Cloudinary for media and static files respectively.","message":"To ensure Django uses Cloudinary for file uploads, `DEFAULT_FILE_STORAGE` must be set to `'cloudinary_storage.storage.MediaCloudinaryStorage'`. Similarly, for static files, `STATICFILES_STORAGE` should be `'cloudinary_storage.storage.StaticCloudinaryStorage'`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install django-cloudinary-storage`.","cause":"The `django-cloudinary-storage` package is not installed or not accessible in your Python environment.","error":"ModuleNotFoundError: No module named 'cloudinary_storage'"},{"fix":"Add `'cloudinary_storage'` to your `INSTALLED_APPS` list in `settings.py`.","cause":"The `cloudinary_storage` app has not been added to your `INSTALLED_APPS` list in `settings.py`.","error":"django.core.exceptions.ImproperlyConfigured: 'cloudinary_storage' is not in your INSTALLED_APPS setting."},{"fix":"Verify that your Cloudinary credentials in `settings.py` (or environment variables) are correct and complete.","cause":"Cloudinary was unable to authenticate due to missing or incorrect API credentials (`CLOUDINARY_CLOUD_NAME`, `CLOUDINARY_API_KEY`, `CLOUDINARY_API_SECRET`).","error":"cloudinary.exceptions.Error: You're not allowed to access this resource"},{"fix":"Change your import statement to `from cloudinary_storage.storage import MediaCloudinaryStorage` (or `StaticCloudinaryStorage`).","cause":"The storage class `MediaCloudinaryStorage` (or `StaticCloudinaryStorage`) was imported from an incorrect path. They reside in the `storage` submodule.","error":"AttributeError: 'module' object has no attribute 'MediaCloudinaryStorage'"}]}