2014-03-25 98 views
0

我有这样的问题:我不会在django引导(22.3.2)模式窗口中加载我的数据。我想要给它的索引加载文本。我不知道我的错误在哪里。氏对我的代码Django自举模态窗口

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">&times;</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> 

你能帮我吗?我不明白我错在哪里。感谢

回答

1

我认为你需要更新你的urls.py定义传递给视图变量名

url(r'^show_modal_topic.html/(?P<topic_id>\d+)/$', views_topics.load_topic), 
+0

谢谢罗汉,我会尝试了这一点,我感谢您抽出宝贵的时间来帮助我 – RoverDar

+0

我有一个问题:模态窗口是在所有页面中,而不是像模态窗口。哪里有问题? – RoverDar

+0

@RoverDar,不确定可能返回的页面内容或ajax处理。 – Rohan