Ahsan
Ahsan

Reputation: 11832

django thousand separator for product price in templates

i have the product price in decimals,

like 15000.0000

now i want to apply thousand separator on it, intcomma filter works fine with decimals as here

but after it i can't apply currency filter, means it didn't work with currency filter.

i want final output of my Price: PKR 15,000.00

any suggestions to get this?

Thanks :)

Upvotes: 1

Views: 1576

Answers (1)

ojii
ojii

Reputation: 4781

The satchmo currency filter requires something that can be converted into a Decimal. However intcomma returns a string, and since it adds the thousand separators, it can no longer be converted to a Decimal.

The solution would be to write a currency_with_intcomma template filter yourself, which first runs through the currency filter and then applies the thousand separators (you can't use the builtin filter for that, you'll have to do it "manullay").

Upvotes: 2

Related Questions