Michael,
Yea I'm already using stringformat in my template.  However, in my
view code is where I create the order.  When the order is added in the
view and I then look at it in the admin the price is displayed as 74.0
instead of 74.00.  Here is part of my view code:

p = float(a['choice']) * int(a['quanity'])
pr = pr + p
pr = round(pr,2)
o = Order()
o.b_name = request.session['orderdetails']['b_firstname'] + " " +
request.session['orderdetails']['b_lastname']
o.b_address = request.session['orderdetails']['b_address']
o.b_city = request.session['orderdetails']['b_city']
o.b_state = request.session['orderdetails']['b_state']
o.b_zip = request.session['orderdetails']['b_zip']
o.amount = pr
o.save()

//////////////

Thanks

On Oct 16, 10:55 pm, Michael <[EMAIL PROTECTED]> wrote:
> You can use "stringformat" in template:
>
> {{ price|stringformat:".2f"}}
>
> On 10/17/07, Greg <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Loren,
> > Yes I got that working  However, I'm still having the problem when the
> > order amount decimal value is .00.  So, if the order amount is 74.00.
> > I only see 74.0 in the admin.  My admin field is setup this way:
>
> > amount = models.DecimalField("Order Amount", max_digits=6,
> > decimal_places=2)
>
> > Thanks
>
> > On Oct 15, 10:19 pm, LorenDavie <[EMAIL PROTECTED]> wrote:
> > > Hi Greg,
>
> > > Within the view you can just use python's built in round function
>
> > > >>> round(92.5698,2)
>
> > > 92.57
>
> > > The full documentation is here:
>
> > >http://docs.python.org/lib/built-in-funcs.html
>
> > > Look for the "round()" function - the second argument is the number of
> > > decimal places you wish to retain.
>
> > > Hope that helps.
>
> > > On Oct 15, 11:06 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > > > Hello,
> > > > I have a view that gets a number.  It's value is 92.5698,  I want to
> > > > find out how to convert that number to two decimal places 92.57 from
> > > > within the view.
>
> > > > Thanks
>
> --
> --
> Michael


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to