I have a product model that has an image_name property.
image_name = models.CharField(max_length=500)
I would like to store inside a static image name such as "super_product.jpg" for example.
In my product view, I am sending the full object as context.
def product_detail_view(request, id):
obj = get_object_or_404(Product, id=id)
context = {
'object': obj
}
return render(request, "products/product_detail.html", context)
The problem is in my html. I tried to do this way:
<img src="{% static {{ object.image_name }} %}" />
But it doesn't seem possible to use static and object property this way.
Does anyone know a way to do it? Thanks in advance!