I have multiple models with multiple DecimalField representing money, like 100.34 EUR.
My goal was to display the currency in the admin list view, like shown in this image.
https://i.stack.imgur.com/fyaaC.png
However I couldn't find a way to do it for every money field.
I tried creating a custom MoneyField, inheriting from DecimalField and changind the unicode representation, but it didn't work.
I also tried with https://github.com/jakewins/django-money but I had no luck.
I investigated the source code of django admin and I finally found the problem:
In django.admin.contrib.admin.util.py in the display_for_field function it checks if the value is an instance of DecimalField. If that's the case it displays it like a Decimal number.
elif isinstance(field, models.DecimalField):
return formats.number_format(value, field.decimal_places)
It makes sense, but it prevents me from displaying the EUR symbol/text in the admin.
How can I solve this problem?
I know that I could simply use a method for each field that display the formatted value as a string, but I wanted to know if there was a DRYer way.
Or create a class like this and inherit from it