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

  • Home
  • SEARCH
  • 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 595855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:06:30+00:00 2026-05-13T16:06:30+00:00

I have a query that orders a table according to a particular field. The

  • 0

I have a query that orders a table according to a particular field. The table is related to one competition, so knowing the position is important.

As the table can grow to have a lot of rows, I have paginate it (25 rows per page) using generic views, but the problem I’ve got is to present the numbered position on the table. This information is generated using a order_by clause.

Result.objects.all().order_by('field')

As I am using generic views to be able to easily paginate, I don’t have any view function that allow me to tweak the results, for example using an enumerate

At first, I thought of using forloop.counter to enumerate the positions without the table, but of course the probelm i when you’re presenting page 100, you’ll still get the numbers as 1,2,3,4,5…25, instead of 2500, 2501, 2502…

I’ve been seen the annotate() method, to see if I can add to each result the position it occupies on the total, but seems that it only add statistical data like the man and so on…

Is there any way of adding to each result of a query the position it occupies?

  • 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-13T16:06:30+00:00Added an answer on May 13, 2026 at 4:06 pm

    If you’re in your template, you can use something like:

    {{ forloop.counter0|add:page.start_index }}
    

    Where start_index on pagination’s page object gives you the 1-based starting index for that page. Of course, the other way around is probably more readable…

    {{ page.start_index|add:forloop.counter0 }}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that successfully grabs the unique products from my products table
I have a query that searches for the all rows in some distance according
I have this great function that parses a field into a pivot table consisting
I have got a MySql query that orders me results by no column (int,
I have got a table that is a result of a (My)SQL query. In
I have a query that according to my slow query log it's a bit
I have an InnoDB table that lists customer orders - this table records the
I am using in C# MYsql .I have query that works if I run
I have a query that basically combines tables of actions and selects from them
I have have this query that i want to execute. SELECT warehouse.expiry_date, pharmacy.expiry_date, drugs.active_substance,

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.