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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:01:52+00:00 2026-05-28T04:01:52+00:00

I am trying to display the total amount that each user would get in

  • 0

I am trying to display the total amount that each user would get in a table on my template. Now when I do print statements in my console, I get the correct values but then when I put {{ total_dollar_amount }} on my template, it only shows me the last value.

Now I thought that I should loop through total_dollar_amount but then it throws an error saying decimal value isn’t iterable.

Anyone know what I am missing?

views.py

def ABD_report(request, *args, **kwargs):
"""
This report will show all 'In Trust For' investments in the system and display all relevant information
"""
from investments.models import Investment
from reports.forms import InTrustForm
context = {}
if request.POST:
    form = InTrustForm(request.agents, request.POST)
    if form.is_valid():
        agents = form.cleaned_data['agents']
        context['selected_agents'] = agents
        investments = Investment.objects.filter(plan__profile__agent__in=agents, plan__ownership_type__code = "itf")
        for i in investments:
            #count all members in each plan
            count = i.plan.planmember_set.all().count()
            #take off the primary member of the account
            count -= 1
            if i.interestoption:
                if i.interestoption.short_label == 'AN':
                    pay_amt = i.pay_amount
                    total_amt = (pay_amt / count)
                    context['total_dollar_amt'] = total_amt
            context['counted'] = count
        context['investments'] = investments
        context['show_report'] = True
else:
    form = InTrustForm(request.agents)

context['form'] = form

return render_to_response('reports/admin/abd_report.html', RequestContext(request, context))
  • 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-28T04:01:53+00:00Added an answer on May 28, 2026 at 4:01 am

    The context variable is a dictionary; each key can only have one value. You’re looping through investments and setting the same two keys, context['total_dollar_amt'] and context['counted'], on each loop – so on each iteration you overwrite the previous value.

    If you want to be able to loop through the counted and total_dollar_amt values for each investment, you need to attach this to the investment object, not set a key in context:

    for i in investments:
        #count all members in each plan
        count = i.plan.planmember_set.all().count()
        #take off the primary member of the account
        count -= 1
        if i.interestoption:
            if i.interestoption.short_label == 'AN':
                pay_amt = i.pay_amount
                total_amt = (pay_amt / count)
                # attach value to the investment
                i.total_dollar_amt = total_amt
        # attach value to the investment
        i.counted = count
    

    Now in your template, you can loop through investments.

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

Sidebar

Related Questions

I'm trying to calculate the total amount won for each user_name in the For
I am trying to display Total Order Amount Per Day in the Present Month.
I'm trying to produce a table that will show the total maturity amounts for
I'm trying to display a row, 'Total', that will do a sum of the
I am trying to display total of each stock with their description in a
I am trying to display a sub-total of the database value bound to each
Im trying to display some files in a web page so the user can
I am trying to display data that I am getting from server through json.
I am trying to display my popover menu whenever the user clicks on a
I'm trying to display all the 'legs' for each of my 'trips' in my

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.