Performance: ListView for displaying collections
MEDIUM IMPACT
This affects page load speed and rendering performance by controlling how many items are fetched and rendered in the browser at once.
from django.views.generic import ListView class ItemListView(ListView): model = Item template_name = 'items.html' paginate_by = 20 # Load 20 items per page
from django.views.generic import ListView class ItemListView(ListView): model = Item template_name = 'items.html' paginate_by = None # No pagination, loads all items at once
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No pagination (all items loaded) | Large number of nodes | Multiple reflows due to large DOM | High paint cost due to many elements | [X] Bad |
| Pagination with 20 items per page | Small number of nodes | Single reflow on page load | Low paint cost | [OK] Good |