I am trying to upload static images to my website for django. I have already been through settings.py and everything is in there that should be because the static css works. My question is how do i code it so that if product id 1 is shown then show this certain picture. I have tried to code it below but the images don't show up.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://ift.tt/mOIMeg">
<html xmlns="http://ift.tt/lH0Osb">
{% load staticfiles %}
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title> The Book Cove </title>
<link rel="stylesheet" type="text/css" href="{% static 'screenstyle.css' %}"/>
</head>
<body>
<div id = "content">
<div id = "header"><p class="heading"> The Book Cove.</p></div>
<div id="navbar">
<ul id="nav">
<li><a href="Homepage.html" id="current">Homepage</a></li>
<li><a href="{% url 'fiction_list' %}">Non-Fiction</a></li>
<li><a href="{% url 'nonfiction_list' %}">Fiction</a></li>
<li><a href="contact.html">Contact Us</a></li>
</ul>
</div>
<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"><a href=" url 'product_detail' product.id%}">{{ product }}</a></li>
<p class="price"> £{{ product.price }}</p>
<p class="author"><em> {{ product.author }} </em></p><hr />
{% if pk.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 %}
{% endfor %}
</ul>
{% elif NonFiction %}
<ul>
{% for product in NonFiction %}
<li id="pname"><a href=" url 'product_detail' product.id%}">{{ product }}</a></li>
<p class ="price"> £{{ product.price }}</p>
<p class ="author"><em> {{ product.author }} </em></p><hr />
{% endfor %}
</ul>
{% else %}
<p> No Products found!</p>
{% endif %}
</div>
<div id = "footer"><p><strong>Copyright © 2011 The Book Cove. All Rights Reserved</strong></p></div>
</div>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire