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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:52:46+00:00 2026-06-10T02:52:46+00:00

This won’t be a long or complex question. I’m just wondering if there is

  • 0

This won’t be a long or complex question. I’m just wondering if there is any simple way to accomplish calculating an average of numbers pulled from the datastore.

At the moment, I have this for loop inside my HTML:

{% for rating_tmp in ratings %}

  {{rating_tmp.rating}}

{% endfor %}

… and it works nicely. Every time I add a value, the for loop places it on the page in a row:

2.5 4.5 2.5 3.5 etc…

Averaging numbers is obviously the sum of the numbers over the number of values. Can I throw more python in there and accomplish this all within the HTML? Or is this something that should go into main.py?

  • 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-10T02:52:47+00:00Added an answer on June 10, 2026 at 2:52 am

    You can probably do this in a Jinja template, but I wouldn’t recommend it. What you’re doing here is pretty clearly logic, not layout, so you should do it in code, and pass it in as a variable or a property. If you change how you average in future, for instance, you should be changing the code that generates it, not the template that displays it.

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

Sidebar

Related Questions

I hope this won't sound like a stupid question. I have a class A
Any idea why this won't work? I m getting tags a user has set
Why won't this code draw parabola? It is as simple as it can be
I'm trying something very basic, but I just can't figure out why this won't
This question has been asked before and there have been windows-specific answers but no
I sure hope this won't be an already answered question or a stupid one.
Anybody got any clue why this won't work with more than 1 date... it
Note: this won't make any sense unless you're very familiar with Java, Spring AOP,
Anyone have any idea why this won't give me back anything? findNoCase(flashvars.ID = '',result.FileContent)
I know this won't be a popular question, because a lot of web designers

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.