Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-smartbase-admin"
version = "1.0.33"
version = "1.0.34"
description = ""
authors = ["SmartBase <info@smartbase.sk>"]
readme = "README.md"
Expand Down
8 changes: 8 additions & 0 deletions src/django_smartbase_admin/engine/filter_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import datetime, timedelta

from django.core.exceptions import ImproperlyConfigured
from django.contrib.postgres.fields import ArrayField
from django.db.models import Q, fields, FilteredRelation, Count
from django.http import JsonResponse
from django.utils import timezone
Expand Down Expand Up @@ -212,6 +213,8 @@ def get_default_label(self):
return found_label[0] if found_label else default_value

def get_base_filter_query_for_parsed_value(self, request, filter_value):
if isinstance(self.model_field, ArrayField):
return Q(**{f"{self.field.filter_field}__contains": [filter_value]})
return Q(**{self.field.filter_field: filter_value})


Expand Down Expand Up @@ -248,6 +251,11 @@ def __init__(
self.select_all_label = select_all_label

def get_base_filter_query_for_parsed_value(self, request, filter_value):
if isinstance(self.model_field, ArrayField):
q_objects = Q()
for value in filter_value:
q_objects |= Q(**{f"{self.field.filter_field}__contains": [value]})
return q_objects
return Q(**{f"{self.field.filter_field}__in": filter_value})

def get_advanced_filter_operators(self):
Expand Down
Loading