Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.6.x] Fixed #20865 -- Fixed raw_id_fields to work with callable lim…

…it_choices_to.

Backport of d53e574 from master
  • Loading branch information...
commit e3e0cf8a0f75ae18bc401182bfbdea2c27bb0244 1 parent 4c90081
@collinanderson collinanderson authored timgraham committed
Showing with 9 additions and 0 deletions.
  1. +2 −0  django/contrib/admin/widgets.py
  2. +7 −0 tests/admin_widgets/tests.py
View
2  django/contrib/admin/widgets.py
@@ -116,6 +116,8 @@ def url_params_from_lookup_dict(lookups):
if lookups and hasattr(lookups, 'items'):
items = []
for k, v in lookups.items():
+ if callable(v):
+ v = v()
if isinstance(v, (tuple, list)):
v = ','.join([str(x) for x in v])
elif isinstance(v, bool):
View
7 tests/admin_widgets/tests.py
@@ -226,6 +226,13 @@ def test_url_params_from_lookup_dict_any_iterable(self):
self.assertEqual(lookup1, {'color__in': 'red,blue'})
self.assertEqual(lookup1, lookup2)
+ def test_url_params_from_lookup_dict_callable(self):
+ def my_callable():
+ return 'works'
+ lookup1 = widgets.url_params_from_lookup_dict({'myfield': my_callable})
+ lookup2 = widgets.url_params_from_lookup_dict({'myfield': my_callable()})
+ self.assertEqual(lookup1, lookup2)
+
class FilteredSelectMultipleWidgetTest(DjangoTestCase):
def test_render(self):
Please sign in to comment.
Something went wrong with that request. Please try again.