From 93d9541ef82deb918f721cb74377e630d271de7d Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 16 Apr 2013 21:59:05 +0200 Subject: Manage OR condition in searches --- ishtar_common/views.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ishtar_common/views.py') diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 42e826103..346edc0d7 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -229,7 +229,17 @@ def get_item(model, func_name, default_name, extra_request_keys=[], or_reqs = [] for req in dct.copy(): for k_hr in HIERARCHIC_FIELDS: - if req.endswith(k_hr + '__pk'): + if type(req) in (list, tuple): + val = dct.pop(req) + q = None + for idx, r in enumerate(req): + if not idx: + q = Q(**{r:val}) + else: + q = q | Q(**{r:val}) + or_reqs.append(q) + break + elif req.endswith(k_hr + '__pk'): val = dct.pop(req) reqs = Q(**{req:val}) req = req[:-2] + '__' -- cgit v1.2.3