Storage settings and backends

Storage settings

Storage settings for static and media files.

SimpleStorage

class common_configs.storage.storage.SimpleStorage

Bases: object

Base class for static and media storage settings

STATIC_URL = '/static/'
MEDIA_URL = '/media/'

BaseCompressStorage

class common_configs.storage.storage.BaseCompressStorage

Bases: common_configs.storage.storage.SimpleStorage

Enables django-compress static files finder

STATICFILES_FINDERS = Value: ['django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'compressor.finders.CompressorFinder']

Env variable: DJANGO_STATICFILES_FINDERS

https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-STATICFILES_FINDERS

AWSCompressStorage

class common_configs.storage.storage.AWSCompressStorage

Bases: common_configs.services.aws.AWS, common_configs.storage.storage.BaseCompressStorage

S3 AWS based storage settings configured for use with django_compressor.

For more info see:

DEFAULT_FILE_STORAGE = Value: 'common_configs.storage.backends.S3MediaStorage'

Env variable: DJANGO_DEFAULT_FILE_STORAGE

https://docs.djangoproject.com/en/dev/ref/settings/#default-file-storage

STATICFILES_STORAGE = Value: 'common_configs.storage.backends.CachedS3StaticStorage'

Env variable: DJANGO_STATICFILES_STORAGE

https://docs.djangoproject.com/en/dev/ref/settings/#staticfiles-storage

COMPRESS_STORAGE = Value: 'common_configs.storage.backends.CachedS3StaticStorage'

Env variable: DJANGO_COMPRESS_STORAGE

http://django-compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_STORAGE

AWS_STORAGE_BUCKET_NAME = SecretValue

Env variable: AWS_STORAGE_BUCKET_NAME

S3 bucket name for stored files

AWS_DEFAULT_ACL = Value: 'public-read'

Env variable: DJANGO_AWS_DEFAULT_ACL

Default S3 ACL settings

AWS_S3_FILE_OVERWRITE = Value: True

Env variable: AWS_S3_FILE_OVERWRITE

Overwrite files in S3 storage

AWS_S3_SECURE_URLS = Value: True

Env variable: AWS_S3_SECURE_URLS

Use secure SSL urls for serving objects from S3

AWS_S3_CUSTOM_DOMAIN = Value

Env variable: AWS_S3_CUSTOM_DOMAIN

Use custom S3 domain

AWS_CLOUDFRONT_URL = Value

Env variable: AWS_CLOUDFRONT_URL

CloudFront endpoint url when serving files from CDN

AWS_QUERYSTRING_AUTH = BooleanValue

Env variable: AWS_QUERYSTRING_AUTH

Generate S3 auth querystring

AWS_IS_GZIPPED = BooleanValue

Env variable: AWS_IS_GZIPPED

Compress uploaded content

AWS_PRELOAD_METADATA = Value: True

Env variable: AWS_PRELOAD_METADATA

Preload S3 metadata

GZIP_CONTENT_TYPES = Value: ('text/css', 'application/javascript', 'application/x-javascript')

Env variable: AWS_GZIP_CONTENT_TYPES

Compressable content types (if AWS_IS_GZIPPED flag is set)

AWS_S3_CALLING_FORMAT

S3 calling format (SubdomainCallingFormat).

AWS_HEADERS

Defines far-future expires (2020-12-31) and cache control (public, max-age=604800, must-revalidate) headers for served files.

STATIC_URL

Base url for static files

MEDIA_URL

Base url for media files

INSTALLED_APPS

Appends collectfast to list of INSTALLED_APPS.

LocalCompressStorage

class common_configs.storage.storage.LocalCompressStorage

Bases: common_configs.storage.storage.BaseCompressStorage

Storage backends

Defines S3 bucket subdirectory storage for static and media files that utilize django-storages and provides storage backends that are compatible with Django Compressor.

Django config

Remember to configure and include Amazon AWS settings config in your settings as well enable user environment variables in the Slug compilation build phase, so the storage backend is able to connect to S3 when executing collectstatic and compress commands:

Note

Django on Heroku: installing NodeJS and Less for static assets compilation and Django and Heroku Cookbook provides more information and build scripts for automatic static files compression during deployment.

Available storage backends

S3 Static and Media storage

class common_configs.storage.backends.S3StaticStorage(*args, **kwargs)

Subclasses storages.backends.s3boto.S3BotoStorage and sets base location for files to /static.

class common_configs.storage.backends.S3MediaStorage(*args, **kwargs)

Subclasses storages.backends.s3boto.S3BotoStorage and sets base location for files to /media.

class common_configs.storage.backends.NonDeletingS3MediaStorage(*args, **kwargs)

Django Compressor-compatible storage

class common_configs.storage.backends.CachedS3BotoStorage(*args, **kwargs)

S3 storage backend that saves the files both remotely and locally.

See http://django_compressor.readthedocs.org/en/latest/remote-storages/

class common_configs.storage.backends.CachedS3StaticStorage(*args, **kwargs)

Mix of the S3StaticStorage and CachedS3BotoStorage, saves files in /static subdirectory

Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.