1

i got some problem with the pagination this is my code template

{% for post in post %}
    <tr class="text-center">
  <td>
    {{forloop.counter|add:post.start_index }} 
 </td>
 {%endfor%}

view.py

def rankpag(request):
with connection.cursor() as cursor:
    cursor.execute("SELECT c.CharName,gu.GuildName,c.Level,c.Family,c.Sex,c.Job,c.K1,c.K2,Str,Dex,Rec,Int,Luc,Wis,HP,MP,SP,g.Country FROM PS_GameData.dbo.Chars c JOIN PS_UserData.dbo.Users_Master m ON m.UserUID=c.UserUID JOIN PS_GameData.dbo.UserMaxGrow g ON g.UserUID=c.UserUID LEFT JOIN PS_GameData.dbo.GuildChars gc ON (gc.CharID=c.CharID and gc.Del=0) LEFT JOIN PS_GameData.dbo.Guilds gu ON gu.GuildID=gc.GuildID ORDER BY c.K1 DESC")
    row = cursor.fetchall()
    paginator = Paginator(row,10)
    page = request.GET.get('page')
    post = paginator.get_page(page)
return render(request,'Ranks.html',{'post':post})

i added a pagination and it's working good but i want to count the row and this what i see enter image description here

Mr.Lio
  • 21
  • 4

1 Answers1

0

Please change variable name post to item. The looping variables should not.

{% for item in post %}
    <tr class="text-center">
  <td>
    {{forloop.counter|item.start_index }} 
 </td>
 {% endfor %}
Riyas Ac
  • 1,553
  • 1
  • 9
  • 23