Tim,
Here is my Price class

class Price(models.Model):
    name = models.DecimalField(max_digits=6, decimal_places=2)
    price_cat = models.ForeignKey(PriceCategory)

    def __str__(self,):
        return str(self.name)

    class Admin:
        pass

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

I guess my 'return str(self.name)' is why my order_by is not working
correctly.  I changed my code to

def __str__(self,):
        return self.name

However, now I get the following error when I try to access the my
page that shows all the choice combinations

'TypeError: coercing to Unicode: need string or buffer, float found'

//////////

Any Suggestions?

Thanks



On Sep 19, 10:20 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > I guess the order_by('price') is working.  However, it's not
> > working how I want it to.  When I do the order_by on price
> > django think that a price of 59.99 is greater than a price of
> > 129.99.  I guess it's looking at the first character and since
> > a 1 is less than a 5 it puts the 129.99 price first.  Does
> > anybody know what I need to change to get it so that Django
> > compares prices instead of strings in my price field?
>
> Your guess is correct...CharFields sort character-by-character.
>
> Sounds like your price field should be a DecimalField (or a
> FloatField, depending on whether your version of Django has the
> newly-added DecimalField) rather than a CharField
>
> -tim


--~--~---------~--~----~------------~-------~--~----~
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