#17662: Adds percentage filter to humanize module
----------------------------------+--------------------------------------
     Reporter:  James Reynolds    |                    Owner:  nobody
         Type:  New feature       |                   Status:  closed
    Component:  contrib.humanize  |                  Version:  master
     Severity:  Normal            |               Resolution:  wontfix
     Keywords:  humanize          |             Triage Stage:  Unreviewed
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+--------------------------------------
Changes (by Johannes Maron):

 * needs_better_patch:  1 => 0
 * has_patch:  1 => 0
 * easy:  1 => 0
 * stage:  Design decision needed => Unreviewed


Comment:

 I am taking the liberty to revisit this ticket and to reopen the
 discussion.

 I believe a lot has changed this implementing a percent filter was
 initially dismissed. We are perfectly capable to render number via
 `floatformat`. Shifting the point/comma by two places and adding a
 `&percent;` does not seem unreachable.

 IMHO we don't need to solve all possible cases here, but the most common
 one. A value or rather ratio between 0 to 1 that is better contextualized
 in percent. Thousand-separators seem unnecessary, since in most cases
 values above 1 would usually not be displayed as percent unless you love
 adding aditional zeros.

 I would propose a filter as simple as `flaotformat` but with a percentage
 sign and a fix decimal shift.


 {{{
 my_value = 1 / 42
 my_value
 >>> 0.023809523809523808
 my_value|percent:2 # in a template
 >>> "2.38 &percent;"
 >>> "2,38 &percent;" # if you use comma
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17662#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.66c803d6c7a92b89bc4620a8da19d034%40djangoproject.com.

Reply via email to