def get_prefetcher(instance, attr):
 prefetcher = None
 attr_found = False
 is_fetched = False
 rel_obj_descriptor = getattr(instance.__class__, attr, None)
 if (rel_obj_descriptor is None):
  try:
   rel_obj = getattr(instance, attr)
   attr_found = True
  except AttributeError:
   pass
 else:
  attr_found = True
  if rel_obj_descriptor:
   if hasattr(rel_obj_descriptor, 'get_prefetch_queryset'):
    prefetcher = rel_obj_descriptor
    if rel_obj_descriptor.is_cached(instance):
     is_fetched = True
   else:
    rel_obj = getattr(instance, attr)
    if hasattr(rel_obj, 'get_prefetch_queryset'):
     prefetcher = rel_obj
 return (prefetcher, rel_obj_descriptor, attr_found, is_fetched)

def get_prefetcher ( instance , attr ) : prefetcher = None attr_found = False is_fetched = False rel_obj_descriptor = getattr ( instance . __class__ , attr , None ) if ( rel_obj_descriptor is None ) : try : rel_obj = getattr ( instance , attr ) attr_found = True except AttributeError : pass else : attr_found = True if rel_obj_descriptor : if hasattr ( rel_obj_descriptor , 'get_prefetch_queryset' ) : prefetcher = rel_obj_descriptor if rel_obj_descriptor . is_cached ( instance ) : is_fetched = True else : rel_obj = getattr ( instance , attr ) if hasattr ( rel_obj , 'get_prefetch_queryset' ) : prefetcher = rel_obj return ( prefetcher , rel_obj_descriptor , attr_found , is_fetched )
for the attribute attr on the given instance .