The N+1 Problem and select_related

When trying to understand the inner-workings of Django last week, I learned about traceback , select_related , and the N+1 query problem. To give some context, I was working on creating a Django list view and was curious about how the get_queryset() that we define is invoked. I found out that by using traceback and viewing the stack, the get_queryset() is called by the BaseListView under the hood. The important part of this is not the traceback itself, but gradually understanding the inner-workings of Django....

August 29, 2024 · 2 min