【发布时间】:2015-02-15 00:56:47
【问题描述】:
所以我试图在 HTML 页面中通过 url /Scan/{id} 发送参数:
<a href="/scan/{{c.id}}">
<button type="button" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> Scan</button>
</a>
url.py:
url(r'^scan/(?P<idcmp>\w{0,50})/$', 'projman.views.scanning', name="scan"),
view.py:
def scanning(request, idcmp):
context = init()
点击a href后的错误
视图 projman.views.scanning 未返回 HttpResponse 对象。它返回 None 。
我在我网站的其他部分有相同的代码,它可以工作。我不知道发生了什么。
【问题讨论】:
-
scanning视图的其余部分在哪里? -
context = init() tmp_component = component.objects.filter(pk=idcmp)[0] print tmp_component print tmp_component.scanned project(request, tmp_component.project.tla) 仅用于测试目的。我不认为问题出在功能上
-
当然在函数里面。错误消息很清楚:您没有返回 HttpResponse。而且,确实,您不会从函数中返回任何内容。还有哪里有问题?