Skip to content

Instantly share code, notes, and snippets.

@kezabelle
Created May 30, 2017 12:34
Show Gist options
  • Save kezabelle/b7ff8058530523b3ff8966d13a320985 to your computer and use it in GitHub Desktop.
Save kezabelle/b7ff8058530523b3ff8966d13a320985 to your computer and use it in GitHub Desktop.
For MrGrj in #django IRC
q = self.request.GET.get('q')
items = ('frq_id', 'line_cls', 'technology_id', 'type_id', 'line_capacity_id', 'el_intf_type_a', 'location_a_id', 'location_z_id', 'comments', 'opened_at', 'opened_by', 'finalised', 'attach_id', 'location_a_id_old', 'offer_deadline', 'location_z_id_old', 'el_intf_type_z', 'cancelled', 'qinq', 'flow_type_id')
itemdicts = ({'{}__contains'.format(item): x} for item in items)
itemqs = (Q(**itemd) for itemd in itemdicts)
itemq = reduce(operator.or_, itemqs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment