Skip to content
Advertisement

Django technology implementation of line breaks by number of posts

My problem

I am making a shopping mall using Django, Bootstrap

I want to implement technology line break when the post becomes 4

I thought if I used col-3 and {$ for %} {% endfor %} it would be divided into four and line breaks. but not working

How can i fix it?

MY models

JavaScript

My views

JavaScript

My urls

JavaScript

My index.html

JavaScript

Advertisement

Answer

The problem is you are putting everything into a single row div.

You can use divisibleby and forloop.counter to test if the record number is a multiple of four, and, if so, to close your row div and open another in your template. See the docs for further details on these template tools.

Index.html

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement