Hello developers, please help solve my problem :

Let's say I have a model :

class Item(db.Model):
    name = db.StringProperty()
    date_posted = db.DateTimeProperty()
    date_expired = db.DateTimeProperty()

sample data:
name   | date_posted | date_expired |
item-a  | 2-jan-2000    | 6-jan-2000    |
item-b  | 5-jan-2000    | 7-jan-2000    |
item-c  | 1-jan-2000    | 8-jan-2000    |
item-d  | 4-jan-2000    | 8-jan-2000    |
item-e  | 3-jan-2000    | 9-jan-2000    |

Let's assume today's date is 9-jan-2000

Now, normally if i want to get Items sorted by date_posted
(descending) I would do this :

items = Item.all().order("-date_posted")

then, if I get only items that is not expired yet :

items = Item.all().filter("date_expired >",
datetime.datetime.utcnow())
name  | date_posted | date_expired |
item-a | 2-jan-2000    | 6-jan-2000    |
item-b | 5-jan-2000    | 7-jan-2000    |
item-c | 1-jan-2000    | 8-jan-2000    |
item-d | 4-jan-2000    | 8-jan-2000    |

But then, if I want order all items that not expired BUT ordered by
the date_posted only, I was hit by the limitation that I have to do
this :

items = Item.all().filter("date_expired >",
datetime.datetime.utcnow()).order("date_expired").order("-
date_posted")

which will return this:
name  | date_posted | date_expired |
item-a | 2-jan-2000    | 6-jan-2000    |
item-b | 5-jan-2000    | 7-jan-2000    |
item-d | 4-jan-2000    | 8-jan-2000    |
item-c | 1-jan-2000    | 8-jan-2000    |


instead of giving me the result that I want (because ordering was done
by date_expired AND date_posted):
name  | date_posted | date_expired |
item-c | 1-jan-2000    | 8-jan-2000    |
item-a | 2-jan-2000    | 6-jan-2000    |
item-b | 5-jan-2000    | 7-jan-2000    |
item-d | 4-jan-2000    | 8-jan-2000    |

Any help?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to