我正在制作一个 Django 项目,一个商业目录。这里我使用了 HTML 页面中的分页。但我收到一条错误消息:
/crawlerapp/search/ 处的 KeyError” 我正在按照链接中给出的程序进行操作:https ://pypi.python.org/pypi/django-pagination/1.0.5 。
我使用分页的 HTML 代码是:
{% load pagination_tags %}
<html>
<head>
<title>{% block head_title %}SearchPage{% endblock %}</title>
</head>
<body>
<h1>{% block title %}The Blue Day, A Search Directory by Abhimanyu Choithramani{% endblock %}</h1>
{% block content %}
<div style="text-transform: uppercase;" id="network-bar">
<dl>
<dd>* <a href="http://127.0.0.1:8000/crawlerapp/">Homepage</a>
* <a href="http://127.0.0.1:8000/crawlerapp/contactus">Contact Us</a></dd>
</dl>
<dl>
<dd class="last" style="float: right;"><a href="http://127.0.0.1:8000/crawlerapp/" title="Blue Day Business Directory">Blue Day Business Directory</a></dd>
</dl>
<div class="network-bar-search"></div>
</div>
<div style="border-top: 1px dashed #6b88a5; margin: 10px;"></div>
<div style="padding: 0 10px 10px; position: relative;">
Search our <a href="http://127.0.0.1:8000/crawlerapp/">Business Directory</a> by entering a business type or name and just click on a Search.
</div>
<div style="position: relative;" id="headerSearchindex">
<form action='' method="GET">
<table style="width: 60%" border="0" cellpadding="1" cellspacing="0">
<tr>
<td class="hsTableTitleCell leftSpaced"> By category: </td>
<td class="hsTableTitleCell leftSpaced">Or by company name:</td>
<td style="width: 300px;"> </td>
</tr>
<tr>
<td class="hsTableBusinessCell leftSpaced"><input type="text" title="Business Category" placeholder="e.g Computer, Restaurants" name="what" autocomplete="off" value=""/></td>
<td class="hsTableCompanyCell leftSpaced"><input type="text" title="Company Name" placeholder="e.g Smith and Sons" name="who" value=""/></td>
<td class="hsTableSearchButtCell leftSpaced"><input name="search_action" type="submit" value="Search"/></td>
</tr>
</table>
</form>
</div>
{% autopaginate crawlerapp %}
<p>You searched for: <strong>{{ query }}</strong></p>
{% if crawlerapp %}
<p>Found {{ crawlerapp|length }} in this Category{{ crawlerapp|pluralize }}.</p>
<ul>
{% for Directory in crawlerapp %}
<li>Business Name: {{ Directory.Bussiness_name }}</li>
Description: {{ Directory.Description }}</br>
Contact Number: {{ Directory.Number }}</br>
Web_URL: {{ Directory.Web_url }}</br>
Address: {% for Adress in Directory.adress_set.all %}{{forloop.counter}}:- {{ Adress.adress_name }}</br>{% endfor %}
Photo: {% for Photos in Directory.photos_set.all %}{{ Photos.Photo_name }}</br>{% endfor %}</br></br>
{% endfor %}
</ul>
{% else %}
<p>No Business matched your search criteria.</p>
{% endif %}
{% paginate %}
</body>
<br><br><br><br><br><br><br><br>
<div id="footer"> © Abhimanyu Choithramani's <a href="http://127.0.0.1:8000/crawlerapp/" >The Blue Day</a> is a Business Search Directory.</div>
</div>
</div>
{% endblock %}
</html>
我是否正确使用变量名进行分页?如果是,那么问题出在哪里?
请帮我。