PacktPublishing / Django-4-by-example

Django 4 by example (4th Edition) published by Packt
https://djangobyexample.com/
MIT License
818 stars 461 forks source link

Chapter 8 (Page 345) #65

Open mbvgua opened 2 months ago

mbvgua commented 2 months ago

the code sample for displaying images to the page is written like so on the book Screenshot from 2024-08-30 13-56-53

In the image tag, the use of quoation marks in the jinja template that are already within the already existing quotation marks gives the impression of them closing, and as such the image will not be loaded. To fix this issue, one should instaed use single quation marks within the jinja template and double quoatations outside of it, as shown below:

    <img src="{% if product.image %} {{ product.image.url }} {% else %} {%static 'img/no_image.png' %} {% endif %}">