- May 25, 2009
- internationalization admin i18n currency field babel decimal
- 0 (after 0 ratings)
The BooleanField and DecimalField
elif blocks are only included in this snippet to give context in the admin_list.py. Insert the CurrencyField block into the file and the Currency fields will display properly in record lists. If you have all of the objects ( Currency Object, Currency Widget, Currency Form Field, and the Currency DB Field ) then all you have to do is use the DB Field object and the Admin app will (should) work properly.
Please let me know if you have any problems.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# Modify: django\contrib\admin\templatetags\admin_list.py from django.utils.currency import Currency # Booleans are special: We use images. elif isinstance(f, models.BooleanField) or isinstance(f, models.NullBooleanField): result_repr = _boolean_icon(field_val) # CurrencyFields are special: use locale currency format. elif isinstance(f, models.fields.special.CurrencyField): if field_val is not None: result_repr = Currency(field_val).format() else: result_repr = EMPTY_CHANGELIST_VALUE # DecimalFields are special: Zero-pad the decimals. elif isinstance(f, models.DecimalField): if field_val is not None: result_repr = ('%%.%sf' % f.decimal_places) % field_val else: result_repr = EMPTY_CHANGELIST_VALUE
More like this
- "Magic Link" Management Command by webology 3 weeks, 5 days ago
- Closest ORM models to a latitude/longitude point by simonw 3 weeks, 5 days ago
- Log the time taken to execute each DB query by kennyx46 3 weeks, 5 days ago
- django database snippet by ItsRLuo 1 month ago
- Serialize a model instance by chriswedgwood 2 months ago