Django Template Not Support Simple Math Calculation

  • Posted on: 27 May 2015
  • By: oon
Django, web framework for perfectionists with deadlines

I used to use Jinja2 for templating, and it support Math calculation [1].

Now when try Django template, I can't calculate simple math (only add available via builtin filter), so I have to implement filter by myself, or using django-mathfilters [2].

What do you need is only install mathfilters with pip then add mathfilters to INSTALLED_APPS on your settings.

[1]http://jinja.pocoo.org/docs/dev/templates/#math
[2]https://pypi.python.org/pypi/django-mathfilters

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.