#2917 closed defect (fixed)
[PATCH] Admin list display doesn't properly display FloatFields
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | major | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In version 0.95 and through trunk on SVN, the admin interface by default doesn't properly display values stored in FloatFields.
The resulting access to the admin page with a FloatField results in the traceback:
If you use a FloatField in the admin list_display, you get an error
rendering the template from line 160 in admin_list.py (TypeError, float
argument required)
- elif isinstance(f, models.FloatField):
- if field_val is not None:
- result_repr = ('%%.%sf' % f.decimal_places) %
field_val
- else:
- result_repr = EMPTY_CHANGELIST_VALUE
Back in April, Dave A recorded a possible fix on the django-user's mailing list, but I wasn't ever able to find a bug about it, or a patch - so I'm supplying it based on what he suggested. It works nicely, and resolves the internal display issue. He asserted:
I think the line should be:
- result_repr = ('%%.%df' % f.decimal_places) % float(field_val)
Attachments (1)
Change History (5)
by , 18 years ago
Attachment: | admin_float_field.diff added |
---|
comment:1 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This appears to be functioning normally in trunk. Can you retest?
comment:2 by , 18 years ago
I still have the same problem, but it's only happening when I use the MySQL backend - don't have the error with the SQLite backend. I'm using trunk also but a couple of weeks old since I can't access the SVN from work due to proxy issues - will update and retest but it looks like the code hasn't changed since my last update.
P.S. Sorry about the duplicate ticket, in a rush and thought I had already checked but obviously not.
comment:3 by , 18 years ago
Just found #1364, looks like I have to update MySQL python bindings. Sorry about the confusion, ignore previous post.
comment:4 by , 17 years ago
I think that including this tiny patch wouldn't bother anyone, while updating MySQL driver might be a struggling task (e.g. when you, just like me, use a shared hosting and don't have much influence on the versions of software installed). Why not to apply it to the trunk?
Patch file for admin list display