wimglenn/djangorestframework-queryfields

Omit expensive field by default

btimby opened this issue · 1 comments

I have a field that I want to exclude by default and only include when requested. This is currently not possible (AFAICT).

Any insight on how I could implement this in a PR?

Thanks.

I needed this too, so I forked and threw something together. Here's my commit. It works for ModelSerializers, but not plain serializers, and has no tests, so it's only a starting point if you want to build a PR off of it.

Also note that QueryFieldsMixin prevents the serialization of fields, but not the querying in whatever uses the serializer. If you're optimizing for expensive queries, instead of expensive serialization, you'll need to optimize elsewhere too.