Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6783669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:53:41+00:00 2026-05-26T16:53:41+00:00

What I want to do is quite simple: I have a model which I

  • 0

What I want to do is quite simple: I have a model which I am running a regroup loop on. Now I want to show the first 4 items of the loop next to each other, and then continue on the next line with the next 4 items until the list is done. If there are no more items, the other cells on the line can stay empty.

I have tried to understand how I can use iterations here, but haven’t been able to figure out how it fits to what I have. Also, I have the idea that it should be possible to do this in a simpler way… Below I copied the code that I have now, which obviously shows the first item of the loop 4 times, then 4 times the second one, etc.

I know there are some similar questions on this website, but I haven’t been able to leverage them to develop a solution for my question. I’m running Python on Google App Engine. Any help is greatly appreciated!

{% regroup communities|dictsort:"in_country" by in_country as community_list %}

{% for in_country in community_list %}
<h2 style="font-size:16px;">{{ in_country.grouper }}</h2>

<table cellspacing="0">
{% for item in in_country.list|dictsort:"name" %}

<tr style="text-align:center;">
 <td width="200px" class='community_table'>
    <img src="{{ item.image }}" style="height:40px;"><br />
    <a href='{{ item.url }}' style="font-size:10px; margin-left:10px;" TARGET = "_blank">{{ item.name }}</a><br />
    {{ item.com_type }}<br />
    {{ item.in_city }}<br />
 </td>

 <td width="200px" class='community_table'>
    <img src="{{ item.image }}" style="height:40px;"><br />
    <a href='{{ item.url }}' style="font-size:10px; margin-left:10px;" TARGET = "_blank">{{ item.name }}</a><br />
    {{ item.com_type }}<br />
    {{ item.in_city }}<br />
 </td>

 <td width="200px" class='community_table'>
    <img src="{{ item.image }}" style="height:40px;"><br />
    <a href='{{ item.url }}' style="font-size:10px; margin-left:10px;" TARGET = "_blank">{{ item.name }}</a><br />
    {{ item.com_type }}<br />
    {{ item.in_city }}<br />
 </td>

 <td width="200px" class='community_table'>
    <img src="{{ item.image }}" style="height:40px;"><br />
    <a href='{{ item.url }}' style="font-size:10px; margin-left:10px;" TARGET = "_blank">{{ item.name }}</a><br />
    {{ item.com_type }}<br />
    {{ item.in_city }}<br />
 </td>

{% endfor %}     
</table>  

{% endfor %}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:53:42+00:00Added an answer on May 26, 2026 at 4:53 pm
    <table cellspacing="0">
    {% for item in in_country.list|dictsort:"name" %}
    
    {% if forloop.counter0|divisibleby:4 %}
    <tr style="text-align:center;">
    {% endif %}
    
     <td width="200px" class='community_table'>
        <img src="{{ item.image }}" style="height:40px;"><br />
        <a href='{{ item.url }}' style="font-size:10px; margin-left:10px;" TARGET = "_blank">{{ item.name }}</a><br />
        {{ item.com_type }}<br />
        {{ item.in_city }}<br />
     </td>
    
    {% if forloop.counter|divisibleby:4 %}
     </tr>
    {% endif %}
    
    {% endfor %}
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually what I want to get is quite simple, I want to get the
I have a quite specific client-server design case and I want to ask for
First I want to apologize for such a silly question but I'm quite new
I have a Competition model which has a corresponding CompetitionEntry model. I'd like to
Question is quite simple. Let's say I have an URL config with line: url(r'^models/(?P<model_group_id>[0-9]+)/(?P<page>\d+)/$',
I have a model which contains a link to sql query that fetches information
Alright, I have a fairly simple design. class Update(models.Model): pub_date = models.DateField() title =
My application is quite simple, but I have some problems when it starts. I
I have a model with an expiration DateField. I want to set up an
Still quite new to Haskell.. I want to read the contents of a file,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.