Reputation: 7448
I'm trying to use parse_date to convert a string into a datetime object before saving in a DateField however it seems to keep returning nothing.Is there something I'm doing wrong?
>>> parse_date('13/07/2016')
>>>
Upvotes: 3
Views: 3306
Reputation: 25539
I'm surprised because django has this function and it just fails silently. But anyway, I played with it and it should be:
parse_date("2016-07-13")
I don't see it well documented and I still use the plain old strptime
to do date/datetime conversion:
import datetime
datetime.datetime.strptime('13/07/2016', "%d/%m/%Y").date()
Upvotes: 9