I’m beginning to learn more about improve my app’s performance, and I know while querying I can tell Django to only load the columns I want from the db by using only like the code below:
book = Books.objects.only(“author”, “title”)
What if I want Django to retrieve books but not retrieve the narration column. Please help. Thank you in advance
I have tried to include all columns except the narration column and that’s too stressful. I believe there should be a way to exclude only one column.
>Solution :
You can use the defer method to tell Django to load every other fields excluding the narration field.
books = Books.objects.defer("narration")