#32920: BaseForm's _clean_fields() and changed_data should access values via
BoundField
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: Chris
Type: | Jerdonek
Cleanup/optimization | Status: assigned
Component: Forms | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Chris Jerdonek):
Here is how to make the failing test I mentioned above (roughly):
{{{
def test_datetime_clean_initial_callable_disabled(self):
- now = datetime.datetime(2006, 10, 25, 14, 30, 45, 123456)
-
class DateTimeForm(forms.Form):
- dt = DateTimeField(initial=lambda: now, disabled=True)
+ dt = DateTimeField(initial=datetime.datetime.now,
disabled=True)
form = DateTimeForm({})
self.assertEqual(form.errors, {})
- self.assertEqual(form.cleaned_data, {'dt': now})
+ cleaned_value = form.cleaned_data['dt']
+ bf = form['dt']
+ self.assertEqual(cleaned_value, bf.initial)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32920#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.b3c31fdc94f3a48eec597b4aae8e1c6c%40djangoproject.com.