Skip to content

Avoid fetching table data in duplicate from ListView mixin#986

Open
mmirate wants to merge 3 commits into
jieter:masterfrom
mmirate:patch-1
Open

Avoid fetching table data in duplicate from ListView mixin#986
mmirate wants to merge 3 commits into
jieter:masterfrom
mmirate:patch-1

Conversation

@mmirate

@mmirate mmirate commented Jan 10, 2025

Copy link
Copy Markdown

Fixes #914. Thank you for your consideration.

@limugob

limugob commented Jun 23, 2025

Copy link
Copy Markdown

The normal implementation of ListView fills beside the variable object_list⁣ the model_name_list variable with the same data. But this PR omits the model_name_list variable.

@mmirate

mmirate commented Jun 26, 2025

Copy link
Copy Markdown
Author

The normal implementation of ListView fills beside the variable object_list⁣ the model_name_list variable with the same data. But this PR omits the model_name_list variable.

I'm trying to understand this, but grep is being uncooperative. Are you perchance referring to django.views.generic.list.MultipleObjectTemplateResponseMixin.get_template_names? Else, can you point me concretely to what you're referring to in Django?

@limugob

limugob commented Jul 1, 2025

Copy link
Copy Markdown

I mean, if I have a ListView for the model Dog then in
https://github.com/django/django/blob/192bc7a7be92e20cc250907fb4083df689715679/django/views/generic/list.py#L145
the template variable dogs_list is filled (together with objects_list). But with this PR only the objects_list variable is filled properly.

Comment thread django_tables2/views.py
from django.core.exceptions import ImproperlyConfigured
from django.views.generic.list import ListView
from django.views.generic.list import (
MultipleObjectMixin as ConfoundingMultipleObjectMixin,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for the alias? Can't we just do from django.views.generic.list import ListView, MultipleObjectMixin?

Comment thread django_tables2/views.py
similar, as presumably ListView.get_context_data is meant to fetch the
same data as this function will fetch directly.
"""
context = (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are multiple overrides of get_context_data, this could skip more than just the MultipleObjectMixin.get_context_data that this PR tries to skip.

I feel as if the current implementation could have unintended breaking side-effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL queries are duplicated when mixing in with MultipleObjectMixin-based views e.g. django-filter

4 participants