Hi all,
I'm currently writing unit tests for defer() and only() under issue #18586. But there appears to a bug when it comes to chaining the two together.
The docs gives the following example for only():
# Final result loads headline and body immediately (only() replaces any existing set of fields).
Entry.objects.defer("body").only("headline", "body")
It turns out that "body" remains a DeferredAttribute when it shouldn't. So in the example above, if the model contained just the two fields "headline" and "body" there wouldn't be any deferred field. In my tests "body" is still a DeferredAttribute.
Am I getting this right or is this actually a bug?
Cheers,
Will