Opened 16 years ago
Last modified 3 years ago
#11294 new Bug
Django administration Model list always shows Decimal with decimal places
| Reported by: | 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 , 16 years ago
| milestone: | 1.1 |
|---|
comment:2 by , 16 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:3 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → Bug |
comment:6 by , 12 years ago
| Version: | 1.1-beta → master |
|---|
The problem here is two folds:
- By default, admin will not localize input values. Not localized input is rendered as
str(value), which isDecimal.__str__. List display usesdisplay_for_field, which localizes value ifUSE_L10Nis true. - When forced to localize (by settings
ModelForm._opts.localized_fields = '__all__'), decimal input still does not honourDecimalField.decimal_placesand 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.
comment:7 by , 12 years ago
| Cc: | added |
|---|
Not a critical bug, thus not in line for 1.1.