2015-10-15 84 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