Check raw SQL queries that Django ORM generates

To find out what queries Django generates behind all that ORM magic, make sure that settings.DEBUG=True, and then run:

>>> from django.db import connection
>>> connection.queries
[{'sql': u'SELECT `auth_user`.`id`, `auth_user`.`username`, 
`auth_user`.`first_name`, `auth_user`.`last_name`, `auth_user`.`email`, 
`auth_user`.`password`, `auth_user`.`is_staff`, `auth_user`.`is_active`, 
`auth_user`.`is_superuser`, `auth_user`.`last_login`, 
`auth_user`.`date_joined` FROM `auth_user` 
WHERE `auth_user`.`id` = 2 ',  'time': '0.002'}, ]

The connection.queries attribute spits out a list of dictionaries of all queries in order of execution. The dictionary contains the actual SQL executed along with the time it took for the same.

To see the last query run, you can use pop:

>>> connection.queries.pop

and to explore further methods, attributes on the connection object, you can always do:

>>> dir(connection.queries)