Created
September 25, 2013 10:15
-
-
Save ryankask/6697692 to your computer and use it in GitHub Desktop.
Use Django's assertNumQueries to show the SQL being executed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with self.assertNumQueries(6) as captured_queries: | |
response = self.client.get(self.url, data=data, **self.headers) | |
for i, query in enumerate(captured_queries.connection.queries): | |
print '*** QUERY {} ***\n {} \n***'.format(i + 1, query['sql']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
captured_queries.connection.queries
can be replaced bycaptured_queries.captured_queries