- In chrome, go to AWS Console & navigate to S3 section of your dashboard
- Under Storage & Content Delivery click create bucket
- Give the bucket a name & select the Oregon region
- Open the bucket you created
- Create new directories for "admin", "media", & "static"
- In the top right corner of the console click on your username, then security credentials
- click Continue to Security Credentials on prompt screen
- On the left nav, click User
- Click Create New User (Make sure the Generate an access key for new user is checked)
- Click Show user security credentials & write down your Access Key ID & your Secret Access Key
- Click the Users tab & the username you just created
- Scroll down to permissions & click Attach User Policy
- With the "Select Policy Template" tab selected, scroll all the way down to S3
- Select "Amazon S3 Full Access" policy & hit Apply Policy
- Navigate back to your S3 dashboard & go into your bucket directory
- Select the "Properties" tab on the right side
- Click the Permissions
- Click Add more permissions
- Under Grantee select authenticated users & select what access users can have on the bucket (List, Upload/Delete, View Permissions, Edit Permissions)
- Click SAVE
- pip install Pillow
- pip install Django-storages
- pip install Django-boto
- pip freeze > requirements.txt
- Add 'storages', to the bottom of your installed apps INSTALLED APPS
- from storages.backends.s3boto import S3BotoStorage
StaticRootS3BotoStorage = lambda: S3BotoStorage(location='static')
- AWS_ACCESS_KEY_ID = 'YOUR_ACCESS_KEY_ID'
- AWS_SECRET_ACCESS_KEY = 'YOUR_SECRET_ACCESS_KEY'
- AWS_STORAGE_BUCKET_NAME = 'YOUR_BUCKET_NAME'
- STATICFILES_STORAGE = 'YOUR_PROJECT.s3utils.StaticRootS3BotoStorage'
- DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
- S3_URL = '//{}.s3.amazonaws.com/'.format(AWS_STORAGE_BUCKET_NAME)
- MEDIA_URL = S3_URL + "media/"
- STATIC_URL = S3_URL + "static/"
- ADMIN_MEDIA_PREFIX = STATIC_URL + "admin/"
- python manage.py collectstatic