I have a developer who stores the binary copy of a file in his table. In ColdFusion, this was acceptable, because he was writing every query by hand, and could simply exclude that field. However, with the Django ORM it is a bit of a problem. The primary table he uses is just for the file, and has a file_name, file_type, file_size, and BinaryField.
The problem is that he has a database-level view that incorporates this field, and it may be that he needs to keep this because other schemas in our big-office Oracle use the view as an exported synonym.
What I advised him to do was to take the BinaryField out of the database-level view, to protect the ORM from reading these large files into memory, as in:
[obj for obj in LicensesDBView.objects.all()]
Or, if he cannot do that, to simply defer the field:
[obj for obj in LicensesDBView.objects.defer('scanned_license').all()]
I was not sure whether to tell him to implement a ModelManager with a get_queryset() method that defers the field, but it made me wonder whether we should have a concept of an "initially deferred" field.
That is, this is a field that starts deferred, and can be pulled into the select using a values iterator or a call to only() or defer(), e.g. the one that cancels prior defers. The concept of "initially deferred" fields would certainly require a new queryset method, such as "nodefer" which is sort of like only but doesn't cause only those fields to load, or rather defer could accept a syntax like defer('-scanned_license') to cancel that previous deferred loading field.
I'm afraid I probably don't understand all the implications of this feature, so I thought I'd bring it up on the list before filing any sort of issue. Its likely this has been discussed before; I cannot do a historical search all the time, especially when ancient history may not be today's read on this issue.