{"id":1457,"library":"django-storages","title":"Django Storages","description":"Django Storages provides a collection of custom storage backends for Django, enabling integration with various cloud storage providers like Amazon S3, Azure Blob Storage, and Google Cloud Storage. It simplifies file management by abstracting away the specifics of each cloud service. The current version is 1.14.6, with active development and regular releases for bug fixes and new features.","status":"active","version":"1.14.6","language":"en","source_language":"en","source_url":"https://github.com/jschneier/django-storages","tags":["django","storage","cloud","s3","azure","gcs","files"],"install":[{"cmd":"pip install django-storages","lang":"bash","label":"Basic Installation"}],"dependencies":[{"reason":"Required for Amazon S3 backend.","package":"boto3","optional":true},{"reason":"Required for Google Cloud Storage backend.","package":"google-cloud-storage","optional":true},{"reason":"Required for Azure Blob Storage backend.","package":"azure-storage-blob","optional":true}],"imports":[{"symbol":"S3Boto3Storage","correct":"from storages.backends.s3boto3 import S3Boto3Storage"},{"symbol":"GoogleCloudStorage","correct":"from storages.backends.gcloud import GoogleCloudStorage"},{"symbol":"AzureStorage","correct":"from storages.backends.azure_storage import AzureStorage"}],"quickstart":{"code":"# In your Django project's settings.py\n\nINSTALLED_APPS = [\n    # ... your other apps\n    'storages',\n]\n\n# --- Example for Amazon S3 Backend ---\n\n# Make sure to install boto3: pip install boto3\n# Set DEFAULT_FILE_STORAGE for media files\nDEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'\n\n# Your AWS settings\nAWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID', '')\nAWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY', '')\nAWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME', '')\nAWS_S3_REGION_NAME = os.environ.get('AWS_S3_REGION_NAME', 'us-east-1') # e.g., 'us-east-1'\n\n# Optional: Set a custom domain for your media files if using a CDN\n# AWS_S3_CUSTOM_DOMAIN = 'your-cdn-domain.com'\n\n# Optional: Control file access. 'public-read' makes files publicly accessible.\n# AWS_DEFAULT_ACL = 'public-read'\n\n# Optional: Don't sign URLs by default (often useful for public access)\n# AWS_QUERYSTRING_AUTH = False\n\n\n# --- Example for Google Cloud Storage Backend (Optional) ---\n# Make sure to install google-cloud-storage: pip install google-cloud-storage\n# For GCS, you typically provide a path to a service account JSON key file\n# or rely on application default credentials.\n# GOOGLE_CLOUD_STORAGE_BUCKET_NAME = os.environ.get('GCS_BUCKET_NAME', '')\n# GOOGLE_CLOUD_STORAGE_JSON_KEY_FILE = os.environ.get('GCS_JSON_KEY_FILE', '/path/to/your/key.json')\n","lang":"python","description":"To quickly set up `django-storages`, add 'storages' to your `INSTALLED_APPS` and configure `DEFAULT_FILE_STORAGE` to point to your chosen backend. Provide the necessary credentials and bucket names, typically sourced from environment variables for security. This example demonstrates Amazon S3 configuration."},"warnings":[{"fix":"Ensure you install the correct backend dependency: `pip install django-storages[s3]` or `pip install boto3` (etc.) for the specific backend you are using.","message":"Forgetting to install the specific Python library for your chosen backend (e.g., `boto3` for S3, `google-cloud-storage` for GCS, `azure-storage-blob` for Azure) will result in `ModuleNotFoundError` or similar import errors when Django tries to initialize the storage backend.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade your Python environment to 3.7+ and your Django project to 3.2+ before upgrading `django-storages`. Consult the `django-storages` changelog for specific version compatibility details.","message":"Versions 1.12+ (including 1.14.x) of `django-storages` require Python 3.7+ and Django 3.2+. Older Python or Django versions are no longer supported and will lead to installation or runtime errors.","severity":"breaking","affected_versions":">=1.12"},{"fix":"Verify that your AWS user's IAM policy grants the necessary permissions (e.g., `s3:PutObject`, `s3:GetObject`, `s3:ListBucket`) to the specified bucket. Double-check that `AWS_S3_REGION_NAME` accurately reflects your bucket's region.","message":"Incorrect AWS IAM permissions or S3 bucket policy can lead to 'Access Denied' errors. Also, a mismatch between `AWS_S3_REGION_NAME` in your settings and the actual region of your S3 bucket is a common pitfall.","severity":"gotcha","affected_versions":"All versions using S3"},{"fix":"Explicitly set `AWS_DEFAULT_ACL = 'public-read'` for publicly accessible files. Set `AWS_QUERYSTRING_AUTH = False` if you want non-signed, non-expiring URLs for your files (e.g., static files served directly from S3).","message":"Misconfiguration of `AWS_DEFAULT_ACL` or `AWS_QUERYSTRING_AUTH` can lead to files being unexpectedly public/private, or URLs that expire too quickly. For example, if `AWS_QUERYSTRING_AUTH` is `True` (default), all URLs will be signed and time-limited, which might not be desired for publicly accessible static assets.","severity":"gotcha","affected_versions":"All versions using S3"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}