Home:ALL Converter>AWS ElasticBeanstalk Django display images

AWS ElasticBeanstalk Django display images

Ask Time:2022-04-28T12:01:20         Author:Kaynan Kaynan Felipe Rodrigues

Json Formatter

i uploaded my Media directory which contains my Images but i cant access it to display my images. My images are correctly being uploaded when i send them, but i cant view them in the page

Im utilizing ElasticBeanstalk and RDS - Mysql

I only configured my RDS everything else like EC2, S3 are automattically configured by ElasticBeanstalk

commands I used on eb:

eb init
eb create
eb deploy

static-files.config:

 option_settings:
     aws:elasticbeanstalk:environment:proxy:staticfiles:
         /static: static
         /media: media

django.config:

 option_settings:
     aws:elasticbeanstalk:container:python:
         WSGIPath: store.wsgi:application

01_packages.config:

 packages:
     yum:
         python3-devel: []
         mariadb-devel: []

models.py:

class Product(models.Model):
    image = models.ImageField(upload_to='product_images/%Y/%m/%d')

settings.py:

MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'

my html:

                <a href="{{product.get_absolute_url}}">
                    <img class="default-img" src="{{product.image.url}}}" alt="550x750">

                </a>

Author:Kaynan Kaynan Felipe Rodrigues,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72037887/aws-elasticbeanstalk-django-display-images
yy