django/django — pull request #2026 by hugorodgerbrown (2013-12-04 14:59:08+00:00)
Title: [1.5.x] Fixed #21523 - support for mock dates in DateField.to_python()

In cases where the value passed in to the DateField.to_python() method
is a real date, and datetime.date is being mocked out, the method would
raise an error attempting to call parse_date on the mock object (as the
parsing requires a string input). I’ve added in a duck-type check for
objects before the parse_date call - if the object has a ‘isoformat()’
method, then call this, and pass it into the parse_date function - which
should return an identical object.