From 9008baad3a40d20d37fc89ec763f36365aa3efb8 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 31 Jul 2020 17:07:14 +0200 Subject: [PATCH] Better alias research, closes #51 --- apps/note/api/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/note/api/views.py b/apps/note/api/views.py index 8a1616ce..a365c343 100644 --- a/apps/note/api/views.py +++ b/apps/note/api/views.py @@ -106,7 +106,10 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet): queryset = super().get_queryset() alias = self.request.query_params.get("alias", ".*") - queryset = queryset.filter(normalized_name__iregex="^" + Alias.normalize(alias))\ + queryset = queryset.filter( + Q(name__regex="^" + alias) + | Q(normalized_name__regex="^" + Alias.normalize(alias)) + | Q(normalized_name__regex="^" + alias.lower()))\ .order_by('name').prefetch_related('note') return queryset