Ticket #15673: t15673.diff

File t15673.diff, 1.9 KB (added by Christopher Grebs, 14 years ago)

Diff with proper testcase and fix for this ticket

  • django/contrib/admin/widgets.py

    diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
    index 1978b3e..61b05b1 100644
    a b def url_params_from_lookup_dict(lookups):  
    100100    if lookups and hasattr(lookups, 'items'):
    101101        items = []
    102102        for k, v in lookups.items():
    103             if isinstance(v, list):
     103            if isinstance(v, (tuple, list)):
    104104                v = u','.join([str(x) for x in v])
    105105            elif isinstance(v, bool):
    106106                # See django.db.fields.BooleanField.get_prep_lookup
  • tests/regressiontests/admin_widgets/tests.py

    diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
    index 7ad74a3..9fde201 100644
    a b from django.contrib import admin  
    88from django.contrib.admin import widgets
    99from django.contrib.admin.widgets import (FilteredSelectMultiple,
    1010    AdminSplitDateTime, AdminFileWidget, ForeignKeyRawIdWidget, AdminRadioSelect,
    11     RelatedFieldWidgetWrapper, ManyToManyRawIdWidget)
     11    RelatedFieldWidgetWrapper, ManyToManyRawIdWidget,
     12    url_params_from_lookup_dict)
    1213from django.core.files.storage import default_storage
    1314from django.core.files.uploadedfile import SimpleUploadedFile
    1415from django.db.models import DateField
    class AdminForeignKeyRawIdWidget(DjangoTestCase):  
    180181            self.assertContains(response,
    181182                'Select a valid choice. That choice is not one of the available choices.')
    182183
     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
    183190
    184191class FilteredSelectMultipleWidgetTest(TestCase):
    185192    def test_render(self):
Back to Top