diff --git a/django/db/models/query.py b/django/db/models/query.py
index cea443a..9144b2a 100644
a
|
b
|
def get_cached_row(klass, row, index_start, max_depth=0, cur_depth=0,
|
752 | 752 | |
753 | 753 | restricted = requested is not None |
754 | 754 | index_end = index_start + len(klass._meta.fields) |
755 | | obj = klass(*row[index_start:index_end]) |
| 755 | fields = row[index_start:index_end] |
| 756 | if not [x for x in fields if x is not None]: |
| 757 | # some select_related() queries return a list of None objects |
| 758 | return None, index_end |
| 759 | obj = klass(*fields) |
756 | 760 | for f in klass._meta.fields: |
757 | 761 | if (not f.rel or (not restricted and f.null) or |
758 | 762 | (restricted and f.name not in requested) or f.rel.parent_link): |
diff --git a/tests/regressiontests/null_fk/models.py b/tests/regressiontests/null_fk/models.py
index 1bc266c..e7d748d 100644
a
|
b
|
__test__ = {'API_TESTS':"""
|
47 | 47 | None |
48 | 48 | |
49 | 49 | >>> comments = Comment.objects.select_related('post__forum__system_info').all() |
50 | | >>> [(c.id, c.post.id) for c in comments] |
51 | | [(1, 1), (2, None)] |
52 | | >>> [(c.comment_text, c.post.title) for c in comments] |
53 | | [(u'My first comment', u'First Post'), (u'My second comment', None)] |
| 50 | >>> [(c.id, c.comment_text, c.post) for c in comments] |
| 51 | [(1, u'My first comment', <Post: First Post>), (2, u'My second comment', None)] |
54 | 52 | |
55 | 53 | """} |