So I have code in my HTML template like this
<div class="blog-content">
{{post.text|safe|linebreaks}}
<p><img src="{{ image_dict.1.url }}" alt=""></p>
</div>
This above renders the image fine in HTML. My view is like this
def post_detail(request, slug):
post = BlogPost.objects.get(slug=slug)
images = post.images.all()
image_dict = {}
for image in images:
image_dict[image.image_order] = image.image
print(image.image)
return render(request, 'blog/post_detail.html', {
'post': post,
'images': images,
'image_dict': image_dict,
})
Basically I'm setting it up so that I can render the images via {{image_dict.image_order.url}}
But I wanna render the images as per following to associate them with each paragraph of text like so
Lorem ipsum dolor sit amet, consectetur adipiscing elit. massa a posuere tempus, urna risus lacinia eros, et euismod.<a><img src="{{ image_dict.1.url }}" alt=""></a>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque.
The above is the content from within Django textfield.
However, while the code within the template evaluates to the image url, for example say for an image with order '1'
<p><img src="{{ image_dict.1.url }}" alt=""></p> becomes
<p><img src="/media/images/codewithlewis.png" alt=""></p>
The exact same code I typed in django's textfield (as written in above string) remains like
<p><img src="{{ image_dict.1.url }}" alt=""></p>
within HTML and nothing gets rendered of course.
I'm fairly new to Django but I feel like I have tried everything. How might I go about fixing this? Thank you.