On Wed, Dec 16, 2009 at 10:13 AM, Jeremy Dunck <[email protected]> wrote:
> This won't work, because deferred fields are descriptors, and
> accessing foo.field would run the query.
>
> Something you could do is foo.deferred_fields.field_name -> Boolean,
> but that seems pretty clunky to me.

You can get at this information now if you really need to::

    >>> e = Entry.objects.defer('body')[0]
    >>> [f.attname for f in e._meta.fields if f.attname not in e.__dict__]
    ['body']

But the point is that deferred fields are an optimization. You
shouldn't need to know which fields are deferred: you should be adding
``defer`` as a last-step optimization once you *know* the fields in
question aren't needed.

IOW, why do I need to inspect the ``Entry`` to figure out what's
deferred? I just *told you* what's deferred in the previous line.

Jacob

--

You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.


Reply via email to