def valid_at(self, valid_date):
        '''Limit current QuerySet to zone valid at a given date'''
        is_valid = db.Q(validity__end__gt=valid_date,
                        validity__start__lte=valid_date)
        no_validity = db.Q(validity=None)
        return self(is_valid | no_validity)
def valid_at ( self , valid_date ) : is_valid = db . Q ( validity__end__gt = valid_date , validity__start__lte = valid_date ) no_validity = db . Q ( validity = None ) return self ( is_valid | no_validity )
Limit current QuerySet to zone valid at a given date