Changeset 7366
- Timestamp:
- 03/26/08 23:20:21 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/newforms-admin/django/newforms/forms.py
r7270 r7366 255 255 initial_value = self.initial.get(name, field.initial) 256 256 if field.widget._has_changed(initial_value, data_value): 257 #print field258 257 return True 259 258 return False django/branches/newforms-admin/django/newforms/widgets.py
r7270 r7366 173 173 # the same as an empty string, if the data or inital value we get 174 174 # is None, replace it w/ u''. 175 data_value = data or u'' 176 initial_value = initial or u'' 175 if data is None: 176 data_value = u'' 177 else: 178 data_value = data 179 if initial is None: 180 initial_value = u'' 181 else: 182 initial_value = initial 177 183 if force_unicode(initial_value) != force_unicode(data_value): 178 184 return True django/branches/newforms-admin/tests/regressiontests/forms/forms.py
r7351 r7366 1718 1718 AttributeError: 'SongForm' object has no attribute 'cleaned_data' 1719 1719 1720 If a field is not given in the data then None is returned for its data. Lets 1721 make sure that when checking for empty_permitted that None is treated 1722 accordingly. 1723 1724 >>> data = {'artist': None, 'song': ''} 1725 >>> form = SongForm(data, empty_permitted=True) 1726 >>> form.is_valid() 1727 True 1728 1729 However, we *really* need to be sure we are checking for None as any data in 1730 initial that returns False on a boolean call needs to be treated literally. 1731 1732 >>> class PriceForm(Form): 1733 ... amount = FloatField() 1734 ... qty = IntegerField() 1735 1736 >>> data = {'amount': '0.0', 'qty': ''} 1737 >>> form = PriceForm(data, initial={'amount': 0.0}, empty_permitted=True) 1738 >>> form.is_valid() 1739 True 1740 1720 1741 """
