Commit d53e5746 authored by Collin Anderson's avatar Collin Anderson Committed by Tim Graham
Browse files

Fixed #20865 -- Fixed raw_id_fields to work with callable limit_choices_to.

parent 709cd2c4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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):
+8 −1
Original line number Diff line number Diff line
@@ -226,6 +226,13 @@ class AdminForeignKeyRawIdWidget(DjangoTestCase):
        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):