Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #7881: Support `__in` lookups in `limit_choices_to` and `raw_id…

…_admin`. Thanks, jamesturk.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8700 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 15416a90163d03e8b2253a1a52d3480c79744b9f 1 parent 21928f2
Jacob Kaplan-Moss authored August 29, 2008
4  django/contrib/admin/views/main.py
@@ -179,6 +179,10 @@ def get_query_set(self):
179 179
                 del lookup_params[key]
180 180
                 lookup_params[smart_str(key)] = value
181 181
 
  182
+            # if key ends with __in, split parameter into separate values
  183
+            if key.endswith('__in'):
  184
+                lookup_params[key] = value.split(',')
  185
+
182 186
         # Apply lookup parameters from the query string.
183 187
         qs = qs.filter(**lookup_params)
184 188
 
2  django/contrib/admin/widgets.py
@@ -102,7 +102,7 @@ def __init__(self, rel, attrs=None):
102 102
     def render(self, name, value, attrs=None):
103 103
         related_url = '../../../%s/%s/' % (self.rel.to._meta.app_label, self.rel.to._meta.object_name.lower())
104 104
         if self.rel.limit_choices_to:
105  
-            url = '?' + '&'.join(['%s=%s' % (k, v) for k, v in self.rel.limit_choices_to.items()])
  105
+            url = '?' + '&'.join(['%s=%s' % (k, ','.join(v)) for k, v in self.rel.limit_choices_to.items()])
106 106
         else:
107 107
             url = ''
108 108
         if not attrs.has_key('class'):

0 notes on commit 15416a9

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