I’m just getting started with the new(ish) class-based views, and I am wondering what’s the best way to get select_related() in there. Here’s my view:
class PostDetailView(DetailView):
model = Post
The post comes from the ‘slug’ in the URL. This works fine, but, I would like to get select_related() in there to reduce the number of queries.
Specify a
querysetinstead ofmodel:(See the docs).