我有这样的问题:我没有在django bootstrap(22.3.2)模式窗口中加载我的数据。我想加载给定索引的文本。我不知道我的错误在哪里。这是我的代码
main.html中
<a data-toggle="modal" href="show_modal_topic.html/{{topic_id}}/" data-target="#myModal">click me</a>
{% include "show_modal_topic.html" %}
URLS.PY
url(r'^show_modal_topic.html/(\d+)/$', views_topics.load_topic),
VIEWS.PY
def load_topic(request, topic_id):
topic = tab_topics.objects.get(id_topic=topic_id)
text_topic = topic.text
return render_to_response("show_modal_topic.html", {
'text_topic': text_topic,
},
context_instance=RequestContext(request))
SHOW_MODAL_TOPIC.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">Opinione</h4>
</div>
<div class="modal-body">
{{text_topic}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
你能帮帮我吗?我无法理解我错在哪里。谢谢
答案 0 :(得分:1)
我认为您需要更新urls.py以定义传递给视图的变量名称
url(r'^show_modal_topic.html/(?P<topic_id>\d+)/$', views_topics.load_topic),