Pakornpat
Pakornpat

Reputation: 21

Filter date by year, please help me find mistakes

i wrote this code to filter date by specific year

class Record(db.Model):
    StartDate = db.DateProperty(required=True)
    Description = db.StringProperty()

    @db.ComputedProperty
    def RequestYear(self):
        return self.StartDate.year

then i try

records = Record.all().filter("RequestYear", 2011) or

records = Record.all().filter("RequestYear = ", 2011)

but records doesn't has any data from my Datastore

Upvotes: 1

Views: 99

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599530

A computed property is actually stored in the datastore. If you've added it since you saved your original data, you won't get any results until you've updated all the existing entities to include the new data - you should be able to just iterate through and re-save them.

Upvotes: 3

Related Questions