Ticket #14158: sm_has_changed.diff

File sm_has_changed.diff, 1.2 KB (added by Anssi Kääriäinen, 14 years ago)
  • django/forms/widgets.py

    diff --git a/django/forms/widgets.py b/django/forms/widgets.py
    index 2e16c35..d390385 100644
    a b class SelectMultiple(Select):  
    527527            data = []
    528528        if len(initial) != len(data):
    529529            return True
    530         for value1, value2 in zip(initial, data):
    531             if force_unicode(value1) != force_unicode(value2):
    532                 return True
    533         return False
     530        initial_set = set([force_unicode(value) for value in initial])
     531        data_set = set([force_unicode(value) for value in data])
     532        if len(data_set - initial_set) == 0:
     533            return False
     534        else:
     535            return True
    534536
    535537class RadioInput(StrAndUnicode):
    536538    """
  • tests/regressiontests/forms/widgets.py

    diff --git a/tests/regressiontests/forms/widgets.py b/tests/regressiontests/forms/widgets.py
    index b8ec789..3fdfbb8 100644
    a b False  
    673673True
    674674>>> w._has_changed([1, 2], [u'1', u'3'])
    675675True
     676>>> w._has_changed([2, 1], [u'1', u'2'])
     677False
    676678
    677679# Choices can be nested one level in order to create HTML optgroups:
    678680>>> w.choices = (('outer1', 'Outer 1'), ('Group "1"', (('inner1', 'Inner 1'), ('inner2', 'Inner 2'))))
Back to Top