| | 51 | def 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 | |
|---|