I noticed that for a form, has_changed is always returning true. On further
investigation, I found that the changed_data was pointing to the Date field
in the form. That took me to forms._get_changed_data function:
for name, field in self.fields.items():
prefixed_name = self.add_prefix(name)
data_value = field.widget.value_from_datadict(self.data,
self.files, prefixed_name)
if not field.show_hidden_initial:
initial_value = self.initial.get(name, field.initial)
## Problem is here. initial_value shows up as datetime.date(1900,1,11) where
as data_value is u'1900-1-11'
## If I change it to initial_value = unicode(self.initial.get(name,
field.initial))
## then the initial_value now is u'1900-01-11' (notice the '01' instead of
just '1' before)
else:
initial_prefixed_name = self.add_initial_prefix(name)
hidden_widget = field.hidden_widget()
initial_value = hidden_widget.value_from_datadict(
self.data, self.files, initial_prefixed_name)
if field.widget._has_changed(initial_value, data_value):
self._changed_data.append(name)
I have described the problem within the code above. This happens on Django
1.2.3 as well as 1.3 alpha1. Any ideas how this can be resolved?
Thanks
Sarang
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.