orschiro
orschiro

Reputation: 21715

Django's DecimalField representation in admin as 0,00 values

I want to represent a price in my model in the form of 0,00. This is the part of my model.

price = models.DecimalField(max_digits=5, decimal_places=2, default=Decimal('0.00'))

However, prices such as 2.10 are still represented as 2.1.

The second issue would be to replace the . with a ,. However default=Decimal('0,00') of course is not possible since , is not a valid literal for Decimal.

Upvotes: 0

Views: 969

Answers (1)

dan-klasson
dan-klasson

Reputation: 14180

Make sure your field in your database state decimal(5,2)

And check out this SO answer regarding replacing the decimal point with a comma.

Upvotes: 1

Related Questions