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?
Thanks On Sep 19, 12:04 am, Greg <[EMAIL PROTECTED]> wrote: > Hello, > I have the following code 's2 = s.sandp.all()' When I do a 'assert > False, s2' I get the following: > > [<Choice: (<Size: 4' x 5'9>, <Price: 169.49>)>, <Choice: (<Size: 5'3 x > 7'6>, <Price: 299.99>)>, <Choice: (<Size: 7'9 x 11'>, <Price: > 449.99>)>, <Choice: (<Size: 2' x 3'>, <Price: 59.99>)>] > > I want to be able to sort the list by the Price. > > /////////// > > I tried the following code > > s2 = s.sandp.order_by('price') > assert False, s2 > > And this is what I get: > > [<Choice: (<Size: 4' x 5'9>, <Price: 169.49>)>, <Choice: (<Size: 5'3 x > 7'6>, <Price: 299.99>)>, <Choice: (<Size: 7'9 x 11'>, <Price: > 449.99>)>, <Choice: (<Size: 2' x 3'>, <Price: 59.99>)>] > > Notice the last element has a price of 59.99. Is there anyway that I > can sort the list so that it's ordered by price? > > Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---