diff -urNad django/db/models/query.py django/db/models/query.py
|
|
|
525 | 525 | If fields are specified, they must be ForeignKey fields and only those |
526 | 526 | related objects are included in the selection. |
527 | 527 | """ |
528 | | depth = kwargs.pop('depth', 0) |
| 528 | depth = kwargs.pop('depth', None) |
529 | 529 | if kwargs: |
530 | 530 | raise TypeError('Unexpected keyword arguments to select_related: %s' |
531 | 531 | % (kwargs.keys(),)) |
… |
… |
|
536 | 536 | obj.query.add_select_related(fields) |
537 | 537 | else: |
538 | 538 | obj.query.select_related = True |
539 | | if depth: |
| 539 | if depth is not None: |
540 | 540 | obj.query.max_depth = depth |
541 | 541 | return obj |
542 | 542 | |
… |
… |
|
781 | 781 | yield iter([]).next() |
782 | 782 | |
783 | 783 | |
784 | | def get_cached_row(klass, row, index_start, max_depth=0, cur_depth=0, |
| 784 | def get_cached_row(klass, row, index_start, max_depth=None, cur_depth=0, |
785 | 785 | requested=None): |
786 | 786 | """ |
787 | 787 | Helper function that recursively returns an object with the specified |
788 | 788 | related attributes already populated. |
789 | 789 | """ |
790 | | if max_depth and requested is None and cur_depth > max_depth: |
| 790 | if max_depth is not None and requested is None and cur_depth > max_depth: |
791 | 791 | # We've recursed deeply enough; stop now. |
792 | 792 | return None |
793 | 793 | |
diff -urNad django/db/models/sql/query.py django/db/models/sql/query.py
|
|
|
953 | 953 | (for example, cur_depth=1 means we are looking at models with direct |
954 | 954 | connections to the root model). |
955 | 955 | """ |
956 | | if not restricted and self.max_depth and cur_depth > self.max_depth: |
| 956 | if not restricted and self.max_depth is not None and cur_depth > self.max_depth: |
957 | 957 | # We've recursed far enough; bail out. |
958 | 958 | return |
959 | 959 | |