Django

Code

Show
Ignore:
Timestamp:
06/29/08 04:40:17 (6 months ago)
Author:
mtredinnick
Message:

Factored out a semi-complex if-test that was used in two places.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/query_utils.py

    r7477 r7782  
    4949        return obj 
    5050 
     51def select_related_descend(field, restricted, requested): 
     52    """ 
     53    Returns True if this field should be used to descend deeper for 
     54    select_related() purposes. Used by both the query construction code 
     55    (sql.query.fill_related_selections()) and the model instance creation code 
     56    (query.get_cached_row()). 
     57    """ 
     58    if not field.rel: 
     59        return False 
     60    if field.rel.parent_link: 
     61        return False 
     62    if restricted and field.name not in requested: 
     63        return False 
     64    if not restricted and field.null: 
     65        return False 
     66    return True 
     67