0

Initially I asked this question, and I wanted to give credit to Daniel. Here is the new issue I have however.

I have this which works great, but I'm having a minor issue.

total_list = plan.investment_set.filter(maturity_date__gte= '%s-1-1' % current_year).values('financial_institution').annotate(Sum('maturity_amount'))

I'm having trouble displaying the financial institution name. When I loop through total list and put loop_variable.financial_institution it shows me the ID but not the name.

Any ideas on how to fix this?

1 Answer 1

1

Assuming that the "financial_institution" model has a name field, I think you could just add it to the list of values you're asking for:

total_list = plan.investment_set.filter(
    maturity_date__gte= '%s-1-1' % current_year
).values(
    'financial_institution',
    'financial_institution__name'
).annotate(Sum('maturity_amount'))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.