this is my codes
class Slide_Item(models.Model):
title = models.CharField(max_length=100, verbose_name="title")
class Meta:
verbose_name = "slide item"
verbose_name_plural = "slide items"
def __str__(self):
return self.title
class Image(models.Model):
post = models.ForeignKey(Slide_Item, on_delete=models.CASCADE, verbose_name="post", related_name="images")
image_file = models.ImageField(verbose_name="image", upload_to="post_image")
title = models.CharField(max_length=100, verbose_name="title")
class Meta:
verbose_name = "image"
verbose_name_plural = "images"
def __str__(self):
return self.title
this is my template
{% extends 'parent/base.html' %}
{% block content %}
<div>
<img src="{{ post.images.first.image_file.url }}" alt="Slider Image" />
</div>
{% endblock %}
It doesn’t show the photo in the template, apparently it is correct, but I don’t know what else to do