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 6895923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:58:14+00:00 2026-05-27T06:58:14+00:00

for item in query_results: num +=1 print num this will give you 1, 2,

  • 0
for item in query_results:
    num +=1
    print num

this will give you 1, 2, 3, 4 etc

I then tried doing this in django templates doing the following

{% for item in query_results %}
<tr>
<td>{{ item.user }}</td>
<td>{{ num|add:"1" }}</td>
</tr>
{% endfor %}

But this only returns 1, 1, 1, 1, 1 etc. This says to me that the 1 isn’t being saved to num each cycle. IS this then not a capability of django templates, or am i just doing it wrong.

  • 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-27T06:58:15+00:00Added an answer on May 27, 2026 at 6:58 am

    Use forloop.counter instead.

    {% for item in query_results %}
    <tr>
    <td>{{ item.user }}</td>
    <td>{{ forloop.counter }}</td>
    </tr>
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This query works: item = db.GqlQuery(SELECT * FROM Item WHERE CSIN = 13)[0] although
This query is failing (RavenDB 1.0.701) var items= RavenSession.Query<Item>().Where(x => 161 193.StartsWith(x.MaterializedPath)).ToList(); Is there
Possible Duplicate: Writing an SQL query to SELECT item from the following table I
Is there a better way to write the following: row_counter = 0 for item
Is there any way to get the work item query results preview pane to
I want to group results of query by the item id and count number
By writing the following query SELECT item_name, YEAR( DATE ) , SUM( item_sold_qty )
In my base page I need to remove an item from the query string
Mysql: i need to get the offset of a item in a query. I
I have a query: SELECT NON EMPTY { [Item].[123] } ON COLUMNS, { [Total

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.