July 2018
Intermediate to advanced
324 pages
8h 14m
English
We are going to use the django-storage (http://django-storages.readthedocs.io/en/latest/), a third-party plugin for implementing a custom storage backend. With the help of Django storage, we are going set up the static and media configuration.
The following is the code snippet, which is required to set up the custom storage for static and media files:
File—gallery/utils.py:
from django.conf import settingsfrom storages.backends.s3boto import S3BotoStorageclass StaticStorage(S3BotoStorage): location = settings.STATICFILES_LOCATION @property def connection(self): if self._connection is None: self._connection = self.connection_class( self.access_key, self.secret_key, calling_format=self.calling_format, host='s3-ap-south-1.amazonaws.com') ...
Read now
Unlock full access