2014-03-25 86 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