you need something like:

News.all().filter('created_at.month >',datetime(2011,3,31,23,59))

but......

your result set will be ordered primarily on created_at coz you are
using an inequality filter, if you do not mind that then ok.

IMHO a better solution to your problem would be if you use an equality
filter based on a computed property:

class BaseArticleModel(polymodel.PolyModel):
    title = db.StringProperty()
    created_at = db.DateProperty(auto_now_add=True)
    updated_at = db.DateProperty(auto_now=True)
    @db.ComputedProperty
    def CM(self):return self.created_at.month

then you can filter on an equality which is much more convenient for
the query at the expense of a little overhead on storage and put
latency:

q = News.all().filter('CM =',1)


happy coding;)


On Apr 1, 7:20 pm, walter <wdv...@gmail.com> wrote:
> My model
>
> class BaseArticleModel(polymodel.PolyModel):
>     title = db.StringProperty()
>     created_at = db.DateProperty(auto_now_add=True)
>     updated_at = db.DateProperty(auto_now=True)
>
> class News(BaseArticleModel):
>     body = db.TextProperty()
>
> I ned get rows by last month. When to do filter like this
>
> q = News.all().filter('created_at.month = ',
> datetime(2011,04,01).month)
>
> I get "IndexError: The query returned fewer than 1 results"

-- 
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 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to