【发布时间】:2015-05-19 08:03:48
【问题描述】:
我正在尝试将静态图像上传到我的 django 网站。我已经通过了 settings.py 并且所有内容都在那里,应该是因为静态 css 有效。我的问题是我如何对其进行编码,以便在显示产品 id 1 时显示此特定图片。我尝试在下面对其进行编码,但图像没有显示出来。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
{% 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>
【问题讨论】:
标签: html css django sqlite static