django - Filter by year and month in ndb model -


what trying , using ndb model database , have model having datetimeproperty() property. want want fetch records particular year , particular month.

class photo(ndb.model):    userid = ndb.stringproperty()     source = ndb.stringproperty()    handle = ndb.stringproperty()    sourceid =ndb.stringproperty()      viewedcount = ndb.integerproperty(default=0)    likedcount = ndb.integerproperty()    uploadedon = ndb.datetimeproperty()    latitude = ndb.floatproperty(default=0)    longitude = ndb.floatproperty(default=0) 

i have field uploadedon has datetime property.

queries (i) fetch records year 2012 (ii) fetch records month of january

i have value in format "uploadedon": "2014-12-27t11:57:01"

import datetime from_date = datetime.datetime(2015,11,30) until_date = datetime.datetime(2016,1,1)     photo.query(ndb.and(photo.uploadedon>from_date, photo.uploadedon<until_date)) 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -