django-planet
Dec. 11, 2023

Django: Defer a model field by default

published by Adam Johnson
in blog Adam Johnson
original entry Django: Defer a model field by default

Some models have one or a few large fields that dominate their per-instance size. For example, take a minimal blog post model:

from django.db import models


class Post(models.Model):
    blog = models.ForeignKey("Blog", on_delete=models.CASCADE)
    title = models.TextField()
    body = models.TextField()

body is typically many times larger ā€¦