django/django — pull request #2027 by hugorodgerbrown (2013-12-04 15:43:13+00:00)
Title: 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.