On Sun, Mar 29, 2009 at 3:01 PM, manuelaraoz <[email protected]> wrote:
> class Person(db.Model):
>
> age = IntegerProperty()
> height_in_cm = IntegerProperty()
>
> how can I sort first by age, but if I have two people with the same
> age, to sort them by height_in_cm
You could create a synthetic property that you sort on instead:
age_height_sort = db.IntegerProperty()
You can set it in a put() override:
def put(self):
self.age_height_sort = self.age*1000 + self.height_in_cm
return super(Person, self).put()
Then you can just order by that synthetic property:
Person.all().order('age_height_sort')
Dave.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---