November 2015
Beginner to intermediate
840 pages
26h 30m
English
Using the shell in Django can help us learn not only how to optimize querysets but also how to profile our querysets to improve them.
While the debug-toolbar is an incredibly useful tool for seeing the global state of a webpage created by Django, it is not equipped to examine querysets granularly. Luckily, Django is. Every QuerySet object comes with a query attribute, as shown in Example 26.8, which prints the SQL code that Django uses to get the information from the database.
Example 26.8: Python Interpreter Code
>>> posts = Post.objects.all() >>> print(posts.query)
Because of the length of the actual SQL, I do not put ...
Read now
Unlock full access