我想在我的django应用程序中使用twitter bootstrap,但我有很多问题。我不明白这个错误。这是我的代码:
main.html中
{% load url from future %}
<a data-toggle="modal" href="{% url name_modal_window str_search=word id_pk=id_pk %}" data-target="#myModal">click me</a>
{% include "modal_window.html" %}
modal_window.html
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">search result</h4>
</div>
<div class="modal-body">
{% for list in lists %}
{{ ... all data result ... }}
{% endfor %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
urls.py
url(r'^modal_window.html/(?P<str_search>[-\w]+)/(?P<id_pk>\d+)$', views.search, name="name_modal_window" ),
views.py
def search(request, str_search, id_pk):
lists = my_table.objects.filter(id_pk=id_pk).filter(text__exact=str_search)
return render_to_response('modal_window.html', {'lists': lists,
},
context_instance=RequestContext(request))
这是我的问题: 1)如果我输入main.html,我不会在模态窗口中加载数据。 2)如果我使用{%url my_view str_search = word id_pk = id_pk%}(如例子)我得到错误NoreverseMatch。 有人可以帮帮我吗?感谢