docs(configuration): Expand S3 storage configuration examples

Update STORAGES configuration examples to include all three storage
backends (default, staticfiles, scripts) with complete option sets.
Add region_name to environment variable example and clarify usage for
S3-compatible services.

Fixes #21864
This commit is contained in:
Martin Hauser
2026-04-08 22:56:26 +02:00
committed by Jeremy Stretch
parent dbb871b75a
commit cb7e97c7f7

View File

@@ -241,21 +241,49 @@ STORAGES = {
Within the `STORAGES` dictionary, `"default"` is used for image uploads, "staticfiles" is for static files and `"scripts"` is used for custom scripts.
If using a remote storage like S3, define the config as `STORAGES[key]["OPTIONS"]` for each storage item as needed. For example:
If using a remote storage such as S3 or an S3-compatible service, define the configuration as `STORAGES[key]["OPTIONS"]` for each storage item as needed. For example:
```python
STORAGES = {
"scripts": {
"BACKEND": "storages.backends.s3boto3.S3Boto3Storage",
"OPTIONS": {
'access_key': 'access key',
STORAGES = {
'default': {
'BACKEND': 'storages.backends.s3.S3Storage',
'OPTIONS': {
'bucket_name': 'netbox',
'access_key': 'access key',
'secret_key': 'secret key',
"allow_overwrite": True,
}
},
'region_name': 'us-east-1',
'endpoint_url': 'https://s3.example.com',
'location': 'media/',
},
},
'staticfiles': {
'BACKEND': 'storages.backends.s3.S3Storage',
'OPTIONS': {
'bucket_name': 'netbox',
'access_key': 'access key',
'secret_key': 'secret key',
'region_name': 'us-east-1',
'endpoint_url': 'https://s3.example.com',
'location': 'static/',
},
},
'scripts': {
'BACKEND': 'storages.backends.s3.S3Storage',
'OPTIONS': {
'bucket_name': 'netbox',
'access_key': 'access key',
'secret_key': 'secret key',
'region_name': 'us-east-1',
'endpoint_url': 'https://s3.example.com',
'location': 'scripts/',
'file_overwrite': True,
},
},
}
```
`bucket_name` is required for `S3Storage`. When using an S3-compatible service, set `region_name` and `endpoint_url` according to your provider.
The specific configuration settings for each storage backend can be found in the [django-storages documentation](https://django-storages.readthedocs.io/en/latest/index.html).
!!! note
@@ -279,6 +307,7 @@ STORAGES = {
'bucket_name': os.environ.get('AWS_STORAGE_BUCKET_NAME'),
'access_key': os.environ.get('AWS_S3_ACCESS_KEY_ID'),
'secret_key': os.environ.get('AWS_S3_SECRET_ACCESS_KEY'),
'region_name': os.environ.get('AWS_S3_REGION_NAME'),
'endpoint_url': os.environ.get('AWS_S3_ENDPOINT_URL'),
'location': 'media/',
}
@@ -289,6 +318,7 @@ STORAGES = {
'bucket_name': os.environ.get('AWS_STORAGE_BUCKET_NAME'),
'access_key': os.environ.get('AWS_S3_ACCESS_KEY_ID'),
'secret_key': os.environ.get('AWS_S3_SECRET_ACCESS_KEY'),
'region_name': os.environ.get('AWS_S3_REGION_NAME'),
'endpoint_url': os.environ.get('AWS_S3_ENDPOINT_URL'),
'location': 'static/',
}