mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #1873 -- Handled multi-valued query parameters in admin changelist filters.
This commit is contained in:
committed by
Mariusz Felisiak
parent
d03dc63177
commit
d2b688b966
@@ -7,6 +7,7 @@ from django.contrib import admin
|
||||
from django.contrib.admin import helpers
|
||||
from django.contrib.admin.utils import (
|
||||
NestedObjects,
|
||||
build_q_object_from_lookup_parameters,
|
||||
display_for_field,
|
||||
display_for_value,
|
||||
flatten,
|
||||
@@ -424,3 +425,17 @@ class UtilsTests(SimpleTestCase):
|
||||
|
||||
def test_quote(self):
|
||||
self.assertEqual(quote("something\nor\nother"), "something_0Aor_0Aother")
|
||||
|
||||
def test_build_q_object_from_lookup_parameters(self):
|
||||
parameters = {
|
||||
"title__in": [["Article 1", "Article 2"]],
|
||||
"hist__iexact": ["history"],
|
||||
"site__pk": [1, 2],
|
||||
}
|
||||
q_obj = build_q_object_from_lookup_parameters(parameters)
|
||||
self.assertEqual(
|
||||
q_obj,
|
||||
models.Q(title__in=["Article 1", "Article 2"])
|
||||
& models.Q(hist__iexact="history")
|
||||
& (models.Q(site__pk=1) | models.Q(site__pk=2)),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user