From a9b4f2a40043cdf8e61dce7e623028ba33ffd6af Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Wed, 26 Jan 2011 08:39:30 +0000 Subject: [PATCH] Tweaked r15303 to avoid O(N) lookup of field name. Thanks to Alex's eagle eyes. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15324 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/sql/query.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index e028800d72..178464c74d 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1367,7 +1367,8 @@ class Query(object): # In case of a recursive FK, use the to_field for # reverse lookups as well if orig_field.model is local_field.model: - target = opts.get_field(field.rel.field_name) + target = opts.get_field_by_name( + field.rel.field_name)[0] else: target = opts.pk orig_opts._join_cache[name] = (table, from_col, to_col,