Performance: Form class definition
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by controlling how forms are rendered and validated on the server and client.
from django import forms class GoodForm(forms.Form): name = forms.CharField() email = forms.EmailField() # Efficient clean method def clean(self): cleaned_data = super().clean() # minimal validation logic return cleaned_data
from django import forms class BadForm(forms.Form): name = forms.CharField() email = forms.EmailField() # Overriding clean method inefficiently def clean(self): cleaned_data = super().clean() # heavy processing or redundant validation for _ in range(1000): pass return cleaned_data
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inefficient form validation | Minimal (server-side) | 0 | 0 | [X] Bad |
| Efficient form validation | Minimal (server-side) | 0 | 0 | [OK] Good |