Performance: Defining models with fields
MEDIUM IMPACT
This affects server response time and initial page load speed by influencing database queries and data serialization.
class Product(models.Model): name = models.CharField(max_length=100) description = models.TextField() price = models.DecimalField(max_digits=10, decimal_places=2) created_at = models.DateTimeField(auto_now_add=True)
class Product(models.Model): name = models.TextField() description = models.TextField() price = models.FloatField() created_at = models.DateTimeField(auto_now_add=True)
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using TextField for short strings | N/A | N/A | N/A | [X] Bad |
| Using CharField with max_length | N/A | N/A | N/A | [OK] Good |