我想点击我的Django页面上的链接,根据我点击的链接显示列表中该名称的新数据库查询过滤器
<tr>
<th>RootGroup List</th>
</tr>
{% for status in root %}
<tr>
<td><a href={{status.rootgroup }}> {{ status.rootgroup }} </a></td>
#I WANT TO CLICK THE LINK AND DISPLAY A NEW DATABASE BASED ON THE NAME WITH A FILTER OF THE NAME
</tr>
{% endfor %}
def display(request):
x = re.search('d.*','% url ''detail'' poll.id %')
rootFilter = Viewroot.objects.filter(rootstatus__gt=0, type = 1, ("LINK NAME")).values('rootgroup').distinct() #RootGroup List
#return render_to_response('status/index.html', { 'root' : rootFilter },context_instance=RequestContext(request))
#return HttpResponse( x.group(0)),render_to_response('status/index.html', {'app' : appFilter})
return HttpResponse("You displayed ", j )`
答案 0 :(得分:0)
基本上,您可以在named groups
模式中使用urls.py
来完成这项工作,例如:
(r'^links/(?P<value>\w+)/$', display)
然后,您可以在视图中访问已保存的网址部分,例如:
def display(request, value=None):
print value
当然,您应该在模板中使用适当的网址:
<td><a href="links/{{ status.rootgroup }}/"> {{ status.rootgroup }} </a></td>