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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:59:55+00:00 2026-05-25T23:59:55+00:00

I guess just generally I’m curious about what operations are allowable in jinja2 brackets,

  • 0

I guess just generally I’m curious about what operations are allowable in jinja2 brackets, e.g. what I’m trying to do is perform an operation on embedded data like so:

{{ round(255*(mileage['chevy'] - mileage['ford']))/1000 }}

This throws the error on traceback:

UndefinedError: ’round’ is undefined

Similarly when I try to use ‘abs’ in a bracketed jinja block, I get an Undefined error–even though they’re both standard lib functions. Is there some way to perform this operation during template-rendering, rather than before passing the data?

  • 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-25T23:59:55+00:00Added an answer on May 25, 2026 at 11:59 pm

    The jinja2 templating language is different from the python language. In jinja2, operation on values are often done during filters : {{ something | operation }}. You can find a list of filters in the jinja2 documentation.

    For example, to round, you can do :

    {{ 42.55|round }}
    

    This will display “42” on the web page. A abs filter exist in the same way.

    Please note that these filters can only be used to alter values before display, and can be used for calculations. Calculations shouldn’t be done in the template anyway.

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

Sidebar

Related Questions

I'm learning about POSIX threads right now, but I guess this is just a
Ok another WPF question, well I guess this is just general .NET. I have
I am new to Linq and extension methods and I guess I just can't
I looked all over on google, I guess I just don't know what to
2^n + 6n^2 + 3n I guess it's just O(2^n), using the highest order
My guess is that this javascript just finds the div called divid and then
I guess I'm wondering if it is ill-advisable to just set: div { overflow:
I guess I'm doing something wrong with my includes but I just can't seem
edit alright, I guess C is painful in nature--Just, this part, is particularly painful.
I'd like to view historical data for guest cpu/memory/IO usage, rather than just current

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.