Performance: TemplateView for simple pages
MEDIUM IMPACT
This affects the server response time and initial page load speed by simplifying view logic and reducing unnecessary processing.
from django.views.generic import TemplateView class AboutView(TemplateView): template_name = 'about.html'
from django.http import HttpResponse def about(request): html = '''<html><body><h1>About Us</h1><p>Welcome to our site.</p></body></html>''' return HttpResponse(html)
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual HTML in view | N/A (server-side) | N/A | N/A | [X] Bad |
| TemplateView with cached template | N/A (server-side) | N/A | N/A | [OK] Good |