diff options
| author | Shreya Bamne <shreya.bamne@gmail.com> | 2021-12-08 15:24:55 +0100 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2021-12-08 15:25:52 +0100 |
| commit | 8a4e5067605e608c3fcbb5ca11e0019eac8b40aa (patch) | |
| tree | 96d96bf001919d322c6f84f562f35b722a2c06fc /django | |
| parent | 2b76f457494414f96d3848a5591909cbb48239e9 (diff) | |
Fixed #19721 -- Allowed admin filters to customize the list separator.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/filters.py | 3 | ||||
| -rw-r--r-- | django/contrib/admin/utils.py | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py index 82dabe4d2c..f6833e57cb 100644 --- a/django/contrib/admin/filters.py +++ b/django/contrib/admin/filters.py @@ -118,6 +118,7 @@ class SimpleListFilter(ListFilter): class FieldListFilter(ListFilter): _field_list_filters = [] _take_priority_index = 0 + list_separator = ',' def __init__(self, field, request, params, model, model_admin, field_path): self.field = field @@ -127,7 +128,7 @@ class FieldListFilter(ListFilter): for p in self.expected_parameters(): if p in params: value = params.pop(p) - self.used_parameters[p] = prepare_lookup_value(p, value) + self.used_parameters[p] = prepare_lookup_value(p, value, self.list_separator) def has_output(self): return True diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py index baaaa9e43f..42d0d96ea6 100644 --- a/django/contrib/admin/utils.py +++ b/django/contrib/admin/utils.py @@ -51,13 +51,13 @@ def lookup_spawns_duplicates(opts, lookup_path): return False -def prepare_lookup_value(key, value): +def prepare_lookup_value(key, value, separator=','): """ Return a lookup value prepared to be used in queryset filtering. """ # if key ends with __in, split parameter into separate values if key.endswith('__in'): - value = value.split(',') + value = value.split(separator) # if key ends with __isnull, special case '' and the string literals 'false' and '0' elif key.endswith('__isnull'): value = value.lower() not in ('', 'false', '0') |
