Opened 10 years ago

Last modified 10 years ago

#23935 closed Bug

DecimalField in admin can show up as Scientific Notation — at Version 4

Reported by: Eric Owned by: Eric
Component: Utilities Version: 1.8alpha1
Severity: Release blocker Keywords: DecimalField admin
Cc: cmawebsite@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Eric)

In the django admin, if a DecimalField's value is lower than 0.000001 displays as Scientific Notation (ex: 1E-7) since python Decimals converts automatically to a scientific notation (exponential) ex: Decimal("0.0000001") = Decimal('1E-7')

this is mostly visible when using Postgresql since DecimalFields with a value of 0 are saved with the decimal precision higher than 6 , ex: 0.00000000 then in the admin instead of seeing 0 or 0.00000000 it is displayed as 0E-8

the bug can be fixed by converting the Decimal to a fixed point value in django.utils.numberformat.format:

link to my branch: https://github.com/xblitz/django/tree/ticket_23935

Change History (4)

comment:1 by Eric, 10 years ago

Description: modified (diff)

comment:2 by Eric, 10 years ago

Description: modified (diff)

comment:3 by Eric, 10 years ago

Owner: changed from nobody to Eric
Status: newassigned

comment:4 by Eric, 10 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top