I'm Having problems loading the static images on the django server. Here is the code that i have, the images are stored in a static folder in the project directory and i have altered the settings.py to include this. Can anyone spot why these wont load? The other items from the database work.
<div id = "titleone"><h1>
{% if NonFiction %} Fiction
{% elif Fiction %} Non-Fiction
{% endif %}
</h1></div>
<div id = "productone">
{% if Fiction %}
<ul>
{% for product in Fiction %}
<li id="pname">{{ product }}</li>
<p class="price"> £{{ product.price }}</p>
<p class="author"><em> {{ product.author }} </em></p><hr />
<div id = "images">
{% if product.id = 1 %}
<img src="{% static 'cat1.png' %}" alt="Fault in our stars" />
{% elif product.id = 2 %}
<img src="{% static 'cat2.png' %}" alt = "Looking for alaska" />
{% elif product.id = 3 %}
<img src="{% static 'cat3.png' %}" alt = "Looking for alaska" />
{% elif product.id = 4 %}
<img src="{% static 'cat4.png' %}" alt = "Looking for alaska" />
{% elif product.id = 5 %}
<img src="{% static 'cat5.png' %}" alt = "Looking for alaska" />
{% endif %}
</div>
{% endfor %}
</ul>
{% elif NonFiction %}
<ul>
{% for product in NonFiction %}
<li id="pname">{{ product }}</li>
<p class ="price"> £{{ product.price }}</p>
<p class ="author"><em> {{ product.author }} </em></p><hr />
<div id = "images">
{% if product.id = 6 %}
<img src="{% static 'cat6.png' %}" alt="Fault in our stars" />
{% elif product.id = 7 %}
<img src="{% static 'cat6.png' %}" alt = "Looking for alaska" />
{% elif product.id = 8 %}
<img src="{% static 'cat6.png' %}" alt = "Looking for alaska" />
{% elif product.id = 9 %}
<img src="{% static 'cat6.png' %}" alt = "Looking for alaska" />
{% elif product.id = 10 %}
<img src="{% static 'cat6.png' %}" alt = "Looking for alaska" />
{% endif %}
</div>
{% endfor %}
</ul>
{% else %}
<p> No Products found!</p>
{% endif %}
</div>
Aucun commentaire:
Enregistrer un commentaire