mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
Fixed #1873 -- Handled multi-valued query parameters in admin changelist filters.
This commit is contained in:
parent
d03dc63177
commit
d2b688b966
7 changed files with 146 additions and 16 deletions
|
|
@ -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)),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue