Performance: Template variables with double braces
MEDIUM IMPACT
This affects the rendering speed of HTML pages by how Django processes template variables before sending HTML to the browser.
{% for item in items %}
<p>{{ item.cached_property }}</p>
{% endfor %}{% for item in items %}
<p>{{ item.get_expensive_property }}</p>
{% endfor %}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using complex method calls in {{ }} inside loops | N/A (server-side) | N/A | Delays initial paint | [X] Bad |
| Using simple variables or cached data in {{ }} | N/A (server-side) | N/A | Faster initial paint | [OK] Good |