Deferring field for select_related

I have a model with a very big field and a special manager to defer that field by default.

class ModelAManager(models.Manager):
    def get_queryset(self, *args, **kwargs):
        return super().get_queryset(*args, **kwargs).defer("big_field")

class ModelA(models.Model):
    big_field = models.TextField()

    objects = ModelAManager()

    class Meta:
        base_manager_name = "objects"

This works fine. When I use


big_field does not get queried from DB.

However I also have ModelB with FK to ModelA and when using select related:


Manager is not used and big_field is queried. Any way around it?
I have lots of places where ‘model_a’ gets select_related. I’d like to be able to defer big field without modifying all these places.

I can suggest you to use this if you want

ModelB.objects.select_related('model_a').only('model_a__name', 'ModelB_field1', 'ModelB_field2')

Manager get_queryset overrides do not propagate to relationships fetched using select_related.

If you want to have the field deferred when using select_related you need to explicitly ask for it by doing


This is detailed in the QuerySet.defer documentation.