﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23370	defer() with inherited models fails	Akis Kesoglou	nobody	"Let's say I have two models: {{{Post(models.Model)}}} and {{{Article(Post)}}} and some data.

Now if I evaluate the query set {{{Post.objects.select_related('article').defer('article__somefield')}}} it will fail with:

{{{
...
  File ""django/db/models/query.py"", line 1457, in get_cached_row
    if (fields[pk_idx] is None or
IndexError: tuple index out of range

}}}

This prevents us from using {{{defer()}}} to optimise our queries to defer loading of large TEXT fields when showing lists of posts.

This is present in master [a81af7f49de7ff3f51f111de28ed3a682f67ea89] and (with a similar traceback) since at least Django 1.6.

I have attached a test project that demonstrates the bug. Add the project to path and run:

{{{
$ ./manage.py migrate
$ ./manage.py testdefer
}}}


"	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed		akiskesoglou@…	Ready for checkin	1	0	0	0	0	0
