From 7da37699e8d7124f5d0cfaba931772333c24ef83 Mon Sep 17 00:00:00 2001 From: Daniel Hillier Date: Wed, 14 Dec 2016 01:06:54 +1100 Subject: Fixed #27594 -- Fixed select_related() with reverse self-referential OneToOneField. Fixed definition of `klass_info['from_parent']` so that two models aren't considered from a parent class if the model classes are the same. --- django/db/models/sql/compiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index c7455ecceb..3e61f8a925 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -713,7 +713,7 @@ class SQLCompiler(object): _, _, _, joins, _ = self.query.setup_joins([related_field_name], opts, root_alias) alias = joins[-1] - from_parent = issubclass(model, opts.model) + from_parent = issubclass(model, opts.model) and model is not opts.model klass_info = { 'model': model, 'field': f, -- cgit v1.3