2015-10-15 126 views
0

我想包括一個名爲group_sharer.html在另一頁頁:包含的頁面不顯示其完整內容

this is the page which i'll include in the home page

{% block content %} 
    <script type="text/javascript" src='/static/media/js/group_sharer.js'></script> 
    <form action="." method="POST" id="my-form"> 
     {% csrf_token %} 
     <select name="campaign" id=""> 
      {% for campaign in campaigns %} 
       <option value="{{campaign.id}}">{{campaign.title}}</option> 
      {% endfor %} 
      <option value="test">test</option> 
     </select> 
     <input type="submit"> 
    </form> 
{% endblock content %} 

伊夫試圖把它與包括到主頁

{% include "group_sharer.html" %} 

但其未交付其完整數據

And this is the home page

我應該怎麼做才能知道在Group_sharer.html實現數據到主頁。

+0

我沒關係兄弟 –

+0

存在的代碼沒有問題,但錯誤是在執行 –

+0

的方式在新的一頁空白頁我想這行 {%包括「group_sharer.html 「%} 但數據丟失像第二張照片的結果 –

回答

0

你的代碼是正確的,是缺少的東西是campaigns

既然你需要這些,你還需要通過這一背景下到模板中包括這就是它。

the docs

一種包括模板,其包括它的模板的上下文中呈現。

+0

@BaHaa - 沒有後顧之憂,玩得開心! – Sayse