Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #15673 -- Allow limit_choices_to to use a tuple for __in filter…

…s. Thanks, EnTeQuAk.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16078 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4da29717fd46234d5b44705646f629800c80982a 1 parent 7478aeb
Jannis Leidel authored April 22, 2011
2  django/contrib/admin/widgets.py
@@ -99,7 +99,7 @@ def url_params_from_lookup_dict(lookups):
99 99
     if lookups and hasattr(lookups, 'items'):
100 100
         items = []
101 101
         for k, v in lookups.items():
102  
-            if isinstance(v, list):
  102
+            if isinstance(v, (tuple, list)):
103 103
                 v = u','.join([str(x) for x in v])
104 104
             elif isinstance(v, bool):
105 105
                 # See django.db.fields.BooleanField.get_prep_lookup
9  tests/regressiontests/admin_widgets/tests.py
@@ -8,7 +8,8 @@
8 8
 from django.contrib.admin import widgets
9 9
 from django.contrib.admin.widgets import (FilteredSelectMultiple,
10 10
     AdminSplitDateTime, AdminFileWidget, ForeignKeyRawIdWidget, AdminRadioSelect,
11  
-    RelatedFieldWidgetWrapper, ManyToManyRawIdWidget)
  11
+    RelatedFieldWidgetWrapper, ManyToManyRawIdWidget,
  12
+    url_params_from_lookup_dict)
12 13
 from django.core.files.storage import default_storage
13 14
 from django.core.files.uploadedfile import SimpleUploadedFile
14 15
 from django.db.models import DateField
@@ -180,6 +181,12 @@ def test_invalid_target_id(self):
180 181
             self.assertContains(response,
181 182
                 'Select a valid choice. That choice is not one of the available choices.')
182 183
 
  184
+    def test_url_params_from_lookup_dict_any_iterable(self):
  185
+        lookup1 = url_params_from_lookup_dict({'color__in': ('red', 'blue')})
  186
+        lookup2 = url_params_from_lookup_dict({'color__in': ['red', 'blue']})
  187
+        self.assertEqual(lookup1, {'color__in': 'red,blue'})
  188
+        self.assertEqual(lookup1, lookup2)
  189
+
183 190
 
184 191
 class FilteredSelectMultipleWidgetTest(TestCase):
185 192
     def test_render(self):

0 notes on commit 4da2971

Please sign in to comment.
Something went wrong with that request. Please try again.