Opened 16 years ago

Last modified 23 months 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

Description

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 by Alex Gaynor, 16 years ago

milestone: 1.1

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

comment:2 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Julien Phalip, 14 years ago

Severity: Normal
Type: Bug

comment:4 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 by Tomek Paczkowski, 12 years ago

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 12 years ago by Tomek Paczkowski (previous) (diff)

comment:7 by Tomek Paczkowski, 12 years ago

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