diff options
| -rw-r--r-- | ishtar_common/views_item.py | 18 | 
1 files changed, 13 insertions, 5 deletions
| diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index d00256877..b53beab90 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -558,18 +558,26 @@ def _manage_hierarchic_fields(dct, and_reqs):                  and_reqs.append(reqs)                  continue -            if req.endswith('town__pk') or req.endswith('towns__pk'): +            if req.endswith('town__pk') or req.endswith('towns__pk') \ +                    or req.endswith('town__cached_label__iexact') \ +                    or req.endswith('towns__cached_label__iexact'): + +                if req.endswith('pk'): +                    suffix = 'pk' +                elif req.endswith('cached_label__iexact'): +                    suffix = 'cached_label__iexact' +                else: +                    continue                  val = _clean_type_val(dct.pop(req))                  reqs = Q(**{req: val}) -                base_req = req[:-2] + '__' -                req = base_req[:] +                base_req = req[:]                  for idx in range(HIERARCHIC_LEVELS): -                    req = req[:-2] + 'parents__pk' +                    req = req[:-(len(suffix))] + 'parents__' + suffix                      q = Q(**{req: val})                      reqs |= q                  req = base_req[:]                  for idx in range(HIERARCHIC_LEVELS): -                    req = req[:-2] + 'children__pk' +                    req = req[:-(len(suffix))] + 'children__' + suffix                      q = Q(**{req: val})                      reqs |= q                  and_reqs.append(reqs) | 
