【发布时间】:2020-08-24 11:29:42
【问题描述】:
我想要下拉菜单中的报告名称,但我无法从字典中获取项目 views.py
def add(request):
report_item = {}
if request.method == "POST":
src=request.POST['src']
width=request.POST['width']
height=request.POST['height']
name=request.POST['name']
report_item = {'src':src, 'width':width, 'height':height, 'name':name}
#template = loader.get_template('report_one.html')
#context={'report_item':report_item}
return render(request, 'report_one.html', report_item)
else:
return render(request, 'report_one.html', report_item)
index.html
li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Reports<span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="dropdown-header">Reports</li>
<li>
<div class="buttons pull-right">
<a href="{% url 'report:reporttest' %}" class="btn btn-xs btn-success" title="Add"><i class="fa fa-plus"></i></a>
</div>
<a href="{% url 'report:reporttwo' %}">Report one</a>
</li>
{% for key, value in report_item.items %}
<li>
<a href="{% url 'report:add' %}">{{ value.name }}</a>
</li>
{% endfor %}
</ul>
我想在下拉菜单中动态添加报表名称
我已成功创建报告,并且报告名称也显示在下拉列表中,但问题是当我单击报告名称时,报告名称将从下拉列表中删除
【问题讨论】:
标签: django