I'd like to display only the numbers that lie in the thousands position for a value i.e. 193000 will be displayed as 193 and so on. How do I achieve this, maybe at the template level?
must have had a pretty long day...this will work well thanks.
2009-09-01 13:21:19
sounds good ... but maybe use integer division so the result is not a float (ie, 193, not 193.000)
pavium
2009-09-01 13:23:07
@Stephen: It's not even Monday!
R. Bemrose
2009-09-01 13:23:38
no problem :). glad to be of help.
Geo
2009-09-01 13:27:29
@Geo: just wanted to tell you I've soreted out my problem@R. Bemrose: :)
2009-09-01 13:54:40
Can the values can exceed 999,999? If so, after dividing by 1000 you'll want to apply modulus 1000.
Philip Kelley
2009-09-01 14:25:22
+1
A:
as long as 193000 is an int, you can just divide it by 1000:
x = 193000.1
y = int(x)/1000
there's no filter already in Django, but you could add one yourself: http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags
Rob Fonseca-Ensor
2009-09-01 13:35:26