Does the model manager reduce database hits?

I understand the point made that using a model manager means that to get the published articles from anywhere we simply call live, hence less typing. But when you mention "in our views, we override get_queryset() and run this filter() on the queryset every time", does this mean that this is more than about repeating code -it's also about efficiency? (I could be reading that entirely incorrectly!!)

By making this model manager are we replacing the one you get by default, i.e. MyModel.objects?

It seems weird that ListView has the attribute self.model, but from looking at the final PublishedPostsMixin class, it does.

Thank you for any thoughts

Sorry You must be a logged in, registered user to answer a question.

Answers

No, it doesn't reduce database hits, it just stops us from repeating ourselves and/or making a mistake in more than one place.

You only lose the MyModel.objects manager if you replace it explicitly, IIRC, but most people will set objects = models.Manager() on a model that has a custom manager attached just for some extra safety and explicitness.

All of the model-focused views, ListView, DetailView, CreateView, UpdateView, and DeleteView have a model attribute. How else would they know what model to grab?

d'oh, I was thinking ListView would have models -plural, but thinking about it that makes no sense
jollyfellow on