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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:44:30+00:00 2026-06-14T13:44:30+00:00

Possible Duplicate: Python-Django: ifchanged template tag This is my present code: {% for eachSc

  • 0

Possible Duplicate:
Python-Django: ifchanged template tag

This is my present code:

{% for eachSc in DBShots1 %}
 <tr>
    {% ifchanged eachSc.laEmpNum %} 

      <td> </td><td> </td>                                  
      <td bgcolor="#FFFACD" width="1%">Tot={{ result }}</td>

    {% endifchanged %}

 </tr>
  <td bgcolor="#FFFACD" width="1%">{{ forloop.counter }} </td> 

  <td bgcolor="#CCFACD" width="1%">{{ eachSc.sName }}</td>

   <td bgcolor="#CCF0F5" width="1%">{{ eachSc.duration }}</td>

  <td bgcolor="#CCFACD" width="1%">{{ eachSc.frames }}</td>

  <td bgcolor="#CCFACD" width="5%">{{ GetEmpDept }} - {{ eachSc.laEmpNum }}</td>

{% endfor %}

From the above code it displays like below:

 Tot=[(u'1046', 5.5), (u'8008', 4.5), (u'8011', 1.3)]

1——-01——2.5————-60——allLayout – 1046

2——-02——2.0————-48——allLayout – 1046

3——-04——1.0————–0——allLayout – 1046

 Tot=[(u'1046', 5.5), (u'8008', 4.5), (u'8011', 1.3)]

4——-03——2.3————-50——allLayout – 8008

5——-06——2.2————-0——-allLayout – 8008

 Tot=[(u'1046', 5.5), (u'8008', 4.5), (u'8011', 1.3)]

6——-05——1.3————-0——-allLayout – 8011

But my output should be display like below:
if empID change(1046,8008,8011) then
{{ forloop.counter }} should start with one(1) and {{ result }} should display first element((1046,5.5) for first ID(1046)
second(8008′,4.5) element for second ID(8008) and so on:

1——-01——2.5————-60——allLayout – 1046

2——-02——2.0————-48——allLayout – 1046

3——-04——1.0————-0——-allLayout – 1046

     Tot=(1046,5.5) 

1——-03——2.3————-50——allLayout – 8008

2——-06——2.2————-0——-allLayout – 8008

    Tot=(8008', 4.5)

1——-05——1.3————-0——-allLayout – 8011

    Tot=(8011', 1.3)
  • 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-06-14T13:44:31+00:00Added an answer on June 14, 2026 at 1:44 pm

    You don’t need to use ifchanged here.

    You should index your result with forloop.counter0 but is not possible with django templating system.

    You can write a custom tag to do this or change your view adding your result to the object context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Understanding Python decorators I was reading a django app source code where
Possible Duplicate: Python or Ruby Interpreter on iOS I just discovered this apps pypad
Possible Duplicate: Python code to pick out all possible combinations from a list? I
Possible Duplicate: Python code to get current function into a variable? is there a
Possible Duplicate: Asynchronous HTTP calls in Python I have a Django view which needs
Possible Duplicate: Python: Split string with multiple delimiters Convert django Charfield \t to tab
Possible Duplicate: Python: Behaviour of increment and decrement operators Hi, I've tried this. ++num
Possible Duplicate: Python: Retrieve items from a set Consider the following code: >>> item1
Possible Duplicate: Python : how to append new elements in a list of list?
Possible Duplicate: Python: What is the best way to check if a list is

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.