Re: DecimalField Problem
On Wed, Jan 8, 2014 at 6:07 PM, Erik Cederstrand <erik+lists@cederstrand.dk> wrote:
Den 08/01/2014 kl. 17.56 skrev Daniel Roseman <daniel@roseman.org.uk>:
>Greatly embarrassed, and thanks for clarifying. Will be more careful when answering next time :-)
Erik
Well, Erik. I appreciate you answering even if it wasn't 100% accurate.
But to post the solution to the issue, just for completeness.
Yes, Django does store the field contents as decimal.Decimal objects. In your templates or if writing out to a file (as I need to do) you need to use the formatting option.
Example using the previously used model field:
str('%.10g' % self.min_inclusive).strip()
This removes all non-significant zeros. So it gives me '0' for a zero.
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3VMznhwXzcKxQwjZommYzKSLYSscSL3fDDQm8OEMgwB4A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home