Amazon S3 Bucket Creation
Learn how to create an Amazon S3 bucket to allow the Django web app to serve its static files including images from a bucket provided by Amazon.
Amazon S3 or Amazon Simple Storage Service is a service that allows websites to serve their static files including images from a bucket provided by Amazon. Instead of serving the images locally from our Django project (not recommended for production), we will use this Amazon service.
Background
Run the app in the following widget and go to the Detail Listing page for one of the listings:
Note: The following code requires three API keys. Please put any random values for now as they are not used at the moment. We will set them up later.
Please note that the AWS Access Key ID and AWS Secret Access Key used here are different from the ones we used earlier to configure the AWS CLI.
""" ASGI config for example project. It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ """ import os from django.core.asgi import get_asgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'example.settings') application = get_asgi_application()
When you reach the Detail Listing page, control-click on any of the images, then select Inspect (or Inspect Element).
After you click on Inspect (or Inspect Element), a console will pop up displaying the HTML code of the page. You will be able to see the path from where the images are being served.
The path of the image above is "/media/l2_p1.png"
which is the path to the media folder of our Django project. By the end of this lesson, the path will change to show the images being served from Amazon ...