Displaying images stored in a database imagefield

I’m trying to understand how to do this. Initially I thought I could pass the data through the view as context and use that to display the image, but its not working at all. Here is where I’m at currently:

model

class CarouselImage(models.Model):
    image = models.ImageField(upload_to='carousel/')
    description = models.CharField(max_length=255, blank=True, null=True)

    def __str__(self):
        return self.description or f"Image {self.id}"

view

class IndexView(generic.TemplateView):
    template_name = "mainapp/index.html"
    carousel_images = CarouselImage.objects.all()
    extra_context={'background_style': 'indexBody',
                   'carousel_images': carousel_images}

html

<img src="{{ image.image.url }}" class="d-block w-100" alt="{{ image.description }}">

Welcome @addohm !

You’re basically correct, but we need more information.

We need to see more of the template. (How are you getting an object named image in the <img> tag?)

What is being rendered? (What is the html that was generated for that template?)

How is this failing? (Are you seeing 404 requests in the console?) Or aren’t there any requests being made?)

Is this in a development environment using runserver, or a production deployment using a real server?

I figured it all out. I’m trying to deploy now but the admin panel is…unhappy?