Posts

Showing posts with the label django

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!

Sql statement for a query with the Django ORM?

from django.db import connection sql_statement = connection.queries.pop() print sql_statement['sql']