Opened 14 years ago

Last modified 10 years ago

#11294 new Bug

Django administration Model list always shows Decimal with decimal places

Reported by: jason@… Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: tomek@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Only in the list_display does the admin interface show DecimalField with precision of .00. In the view of an object in the Model, 0.00, for example, would be shown as 0, without the precision. I'd say the same rendering should be for both, and that displaying without the .00 is preferred.

Change History (7)

comment:1 Changed 14 years ago by Alex Gaynor

milestone: 1.1

Not a critical bug, thus not in line for 1.1.

comment:2 Changed 13 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:3 Changed 12 years ago by Julien Phalip

Severity: Normal
Type: Bug

comment:4 Changed 11 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 11 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 Changed 10 years ago by Tomek Paczkowski

Version: 1.1-betamaster

The problem here is two folds:

  1. By default, admin will not localize input values. Not localized input is rendered as str(value), which is Decimal.__str__. List display uses display_for_field, which localizes value if USE_L10N is true.
  2. When forced to localize (by settings ModelForm._opts.localized_fields = '__all__'), decimal input still does not honour DecimalField.decimal_places and is displayed differently from list.

Fix for 2. is easy, overriding _format_value in NumberInput to correctly use number_format with decimal_places.
Fix for 1. is not easy, if not impossible, tickets #13032 and #13546 mention problems with localizing inputs by default. At least we can better document current admin behaviour and include instructions to change it. Better yet, would be to include another ModelAdmin option to control localized_fields in generated ModelForm classes.

Last edited 10 years ago by Tomek Paczkowski (previous) (diff)

comment:7 Changed 10 years ago by Tomek Paczkowski

Cc: tomek@… added
Note: See TracTickets for help on using tickets.
Back to Top