Skip to content

Instantly share code, notes, and snippets.

@toastdriven
Created November 18, 2011 17:27

Revisions

  1. toastdriven created this gist Nov 18, 2011.
    6 changes: 6 additions & 0 deletions programmatic_filters.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    import operator
    from haystack.query import SearchQuerySet, SQ

    stuff = ['foo', 'bar', 'baz']
    the_filters = reduce(operator.or_, [SQ(tag=tag_name) for tag_name in stuff])
    sqs = SearchQuerySet().filter(the_filters)