Jul 4, 2013

Converting unicode date to datetime object.

In a django template i had something like:

value="{{ query_date|date:'%d/%m/%Y' }}"

And in my view i wanted a date not an unicoded date.
So i did this in a view to parse the unicode and convert it to datetime object. 

from datetime import datetime
query_date_obj = datetime.strptime(query_date, "%d/%m/%Y")

Ciao!