When thinking about deploying your static files for your Django Web Application, there are a few options to choose from:
- Amazon S3
- Apache Liquid
- Azure Storage
- Digital Ocean
- Google Cloud Storage
Today we will be looking at Amazon S3 and how to configure it to be ready to host your Static Files from Django.
First you will have to go create an AWS account, you can signup for the free tier account and it is a great place to start playing around and testing out your solutions. You will be asked to provide a credit card but you will not be charged until you have used up the free tier resources, so have a look at your billing dashboard and keep an eye out that your usage does not reach your free tier limit.
Once you are registered and logged into your AWS management console, go to the very top and type in S3 and select the first option, this will take you to the S3 service.
You can click on create a bucket, which will take you to the configuration page. From here:
- Choose a name for your bucket, this name will have to be unique so you might have to try a few options.
- Select your region you want your S3 bucket to be hosted in.
- Uncheck the option that states, Block all public access.
- The rest we can leave at defaults for now.
Now our Bucket is created but will still not be able to work fully with our Django app. We have to create a bucket policy first to allow a public read and getObject to our S3 bucket.
Save your configuration and now at the top under your bucket name you will see that it states Publicly accessible in red, which means now we are able to access that content in the bucket outside of our AWS environment, which means our Django app will now be able to read the objects within our buckets.