Using the slice filter with context data from a Django QuerySet

前端 未结 1 665
抹茶落季
抹茶落季 2021-01-29 07:25

I am trying to split a list from my model across two columns, using this html code in the template:

< div class =\"col-md-6\" >
{%for value in object_list          


        
相关标签:
1条回答
  • 2021-01-29 07:54

    I think, what you need is this:

    <table>
      <tr>
        <th>URL</th>
        <th>SITE</th>
      </tr>
      {% for value in object_list %}
      <tr>
        <td><a href="/sites/{{value.url}}/">{{value.url}}</a></td>
        <td>{{value.Site}}</td>
      </tr>
     {% endfor %}
    </table>
    

    URLs and Sites will be displayed as a table.

    0 讨论(0)
提交回复
热议问题