It might have been nicer to turn filter() into a generator, but this approach is certainly easier and fine. Hopefully we will be able to switch to MongoEngine in the future, which will make our data layer very nice for things like this.