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')
>>>
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With